php - Symfony2 entity manager get not working all the time -
i found strange issue in symfony2 (maybe not strange , did mistake somewhere):
i'm trying call entity manager method defined in entity class:
//entity/organisation.php /** * @return string */ public function getapiurl(){ return $this->api_url; }
and don't return value same object
the call made controller method:
private function addapilog($organisationid, $calltype, $eventinfo){ $em = $this->getentitymanager(); $organisation = $em->find('\webagenda\entity\organisation', $organisationid); if (null === $organisation) { die(); } $apiurl = $organisation->getapiurl(); $apikey = $organisation->getapikey(); $fc = fopen("debug_api_log.txt", "a"); fwrite($fc, date("y-m-d h:i:s")." - ".$calltype." - ".$organisationid." - ".$organisation->getname()." - ".$apiurl."\n"); fclose($fc); if(trim($apiurl)!='' && $apiurl!='-'){
the 'addapilog()' methos called different methods depending on action , though organisationid passed same , organisation object, $organisation->getapiurl() method doesn't return , $organisation->getname(), return correct value: http://screencast.com/t/hq2nunfwsg9
what missing? why don't values?
thank you!
replace $em = $this->getentitymanager();
with $em = $this->getdoctrine()->getmanager();
and use repository
$myrepo = $em->getrepository('namespacemybundle:organisation'); $organisation = $myrepo->find($organisationid);
Comments
Post a Comment