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

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -