Ryan
Ryan

Reputation: 5066

How do I get the short name of an entity in Symfony2?

How does Symfony2 determine the short name of a Doctrine entity?

For example Acme\DefaultBundle\Entity\User becomes AcmeDefaultBundle:User.

What about Acme\DefaultBundle\Entity\Group\UserGroup?

Upvotes: 1

Views: 2418

Answers (1)

Ryan
Ryan

Reputation: 5066

Acme\DefaultBundle\Entity\Group\UserGroup would be AcmeDefaultBundle:Group\UserGroup.

The part of the short name after the colon, is just appended directly to the converted namespace.

From Doctrine\ORM\Mapping\ClassMetadataFactory:

protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
{
    return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
}

Upvotes: 1

Related Questions