Daniel
Daniel

Reputation: 179

2 Level Entity Folder in Symfony 2

I have a two level entity folder in a Symfony2 bundle:

CommonBundle/Entity/EntityFolder1/EntityA.php
CommonBundle/Entity/EntityFolder2
CommonBundle/Entity/EntityFolder3
CommonBundle/Entity/EntityFolder4

When I try to get the repositories for an entity that is within one of the folders:

$product = $this->getDoctrine()->getRepository('CommonBundle:EntityA')->find(1); 

Symfony doesn't recognize this CommonBundle:EntityA.

I also tried with CommonBundle:EntityFolder1:EntityA.

Warning: class_parents(): Class CommonBundle\Entity\EntityA does not exist and could not be loaded in

Upvotes: 11

Views: 3334

Answers (2)

Elnur Abdurrakhimov
Elnur Abdurrakhimov

Reputation: 44841

It's CommonBundle:EntityFolder1\EntityA.

Upvotes: 21

Carlos Granados
Carlos Granados

Reputation: 11351

Use the full class name of your entity:

$product = $this->getDoctrine()
                ->getRepository('Acme\CommonBundle\Entity\EntityFolder1\EntityA')
                ->find(1);

Upvotes: 1

Related Questions