symfony - resolve target entities compiler pass -


i'm trying create bundle sets resolve target entities based on parameter values. i've found similar questions on internet seems answers there not working me. maybe i'm missing something. please check i'm going wrong!

here build method bundle class:

public function build(containerbuilder $container) {     parent::build($container);     $container->addcompilerpass(new resolvetargetentitiescompilerpass()); } 

and here process method in compiler pass:

public function process(containerbuilder $container) {     $def = $container->finddefinition('doctrine.orm.listeners.resolve_target_entity');     $def->addmethodcall('addresolvetargetentity', array(         'test\basebundle\entity\contenttype', $container->getparameter('test_base.content_type_entity_class'), array()     ));     $def->addmethodcall('addresolvetargetentity', array(         'test\basebundle\entity\path', $container->getparameter('test_base.path_entity_class'), array()     )); } 

as far know it's need need doctrine\common\persistence\mapping\mappingexception message class test\basebundle\entity\contenttype not exist.

edit:

in case contenttype interface. here class passed test_base.content_type_entity_class parameter:

namespace test\baseexamplebundle\entity;  use doctrine\orm\mapping orm; use test\basebundle\entity\contenttype contenttypeinterface;  /**  * contenttype  *  * @orm\table()  * @orm\entity  */ class contenttype implements contenttypeinterface {     /**      * @var integer      *      * @orm\column(name="id", type="integer")      * @orm\id      * @orm\generatedvalue(strategy="auto")      */     private $id;      /**      * @var string      *      * @orm\column(name="action", type="string", length=255)      */     private $action;      /**      * @var string      *      * @orm\column(name="codename", type="string", length=255)      */     private $codename;       /**      * id      *      * @return integer      */     public function getid()     {         return $this->id;     }      /**      * @inheritdoc      */     public function setaction($action)     {         $this->action = $action;          return $this;     }      /**      * @inheritdoc      */     public function getaction()     {         return $this->action;     }      /**      * @inheritdoc      */     public function getcodename()     {         return $this->codename;     }      /**      * @inheritdoc      */     public function setcodename($codename)     {         $this->codename = $codename;         return $this;     } } 

just make clear value of test_base.content_type_entity_class parameter set test\baseexamplebundle\entity\contenttype.

edit:

i've found out it's working when put @ least 1 entry in doctrine.orm.resolve_target_entities configuration key.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -