mongodb - Not able to pass values to twig file symfony2 -
mongodb - Not able to pass values to twig file symfony2 -
hi have next function in controller symfony2
class organisationtaskcontroller extends controller { public function setcontainer(\symfony\component\dependencyinjection \containerinterface $container = null) { parent::setcontainer($container); $this->containerinitialized(); } /** * perform operations after controller initialized , container set. */ public function containerinitialized() { $dbname = $_session['_sf2_attributes']['dbname']; $orgdm = $this->get('work_core.common_functions')->getdocumentmanager('org', $dbname); $coredm = $this->get('work_core.common_functions')->getdocumentmanager('core', ''); $organisationlogodetails = $orgdm->getrepository( 'work\organisationbundle \document\organisationconfig' )->findoneby( array( 'isactive' => true ) ); if ($organisationlogodetails->getlogofileid() != "") { $orglogo = $organisationlogodetails->getlogofileid(); } else { $orglogo = ""; } //get organisation name global organisation $globalorgname = $coredm->getrepository('work\corebundle\document\organisation')->findoneby( array('shortname' => $_session['_sf2_attributes']['shortname']) ); $orgname = $globalorgname->getname(); $commonvariablesarrays = array( 'orglogo' => $orglogo, 'orgname' => $orgname ); } }
i want pass $commonvariablesarrays variable in layout.html.twig.without rendering.
this function called before function of controller writing mutual code need utilize in layout.html.twig file mutual layout application. problem unable set $arrays variable pass "layout.html.twig". , extending layout on each page like: {% extends 'workcorebundle::layout.html.twig' %}
so can plese help me how access $array variable in layout file.great total you.if going pass variable like: homecoming $this->render('workorganisationbundle:layout:layout.html.twig', array('aray'=>$commonvariablesarrays ));
this throwing error variable aray not exist.
if containerinitialized kind of __construct in controller, need set $this->commonvariablesarrays there , can retrieve mutual array controller::actions()
anyways, take different route , mutual assignements elsewhere, illustration in service. can inject service in controllers need it, or inject controller::actions() property using http://jmsyst.com/bundles/jmsdiextrabundle (although recommendation, can accomplish using standard symfony without extra-bundles)
another way accomplish looking using event handlers. take here: http://symfony.com/doc/current/components/http_kernel/introduction.html
i don't understand concept of passing values template without rendering. exactly when render, key->values assigned in template.
mongodb symfony2
Comments
Post a Comment