Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 462
Daniel Avatar asked Sep 09 '12 02:09

Daniel


2 Answers

It's CommonBundle:EntityFolder1\EntityA.

like image 85
Elnur Abdurrakhimov Avatar answered Dec 15 '22 00:12

Elnur Abdurrakhimov


Use the full class name of your entity:

$product = $this->getDoctrine()
                ->getRepository('Acme\CommonBundle\Entity\EntityFolder1\EntityA')
                ->find(1);
like image 40
Carlos Granados Avatar answered Dec 14 '22 23:12

Carlos Granados