1 pièce(s) jointe(s)
Lecture dump twig pour récupérer les valeurs
Bonjour,
J'ai fait une requête comme ceux-ci :
$sReq=$this->createQueryBuilder('enstrt');
$sReq->leftJoin('enstrt.uprocenstrt','comp')
->leftJoin('comp.uproc_id','comp2')
->addSelect('comp,comp2')
->where('enstrt.enstrt_id= :id')
->setParameter('id', $p_iIdEnsTrtSens);
return $sReq->getQuery()->getResult();
qui me retourne ceux-ci sous phpmyadmin :
Pièce jointe 136329
Dans mon controller, je passe le résultat au twig via la variable $tenstrtuproc qui de type tableau.
Losrque je fais un dump de cette variable dans mon twig, il me retourne ceci :
array (size=1)
0 =>
object(Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoEnsTrt)[1286]
private 'typefluxenstrt' =>
object(Doctrine\ORM\PersistentCollection)[1292]
&object(Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoEnsTrt)[1286]
object(Doctrine\ORM\EntityManager)[1239]
private 'backRefFieldName' => string 'enstrttypeflux' (length=14)
object(Doctrine\ORM\Mapping\ClassMetadata)[1287]
private 'isDirty' => boolean false
private 'initialized' => boolean false
object(Doctrine\Common\Collections\ArrayCollection)[1308]
object(Doctrine\ORM\PersistentCollection)[1317]
&object(Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoEnsTrt)[1286]
object(Doctrine\ORM\EntityManager)[1239]
private 'backRefFieldName' => string 'enstrt_id' (length=9)
object(Doctrine\ORM\Mapping\ClassMetadata)[1309]
private 'isDirty' => boolean false
private 'initialized' => boolean true
object(Doctrine\Common\Collections\ArrayCollection)[1327]
private 'lesens' =>
object(Proxies\__CG__\Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoSensTrt)[1351]
private '_entityPersister' =>
object(Doctrine\ORM\Persisters\BasicEntityPersister)[1350]
...
private '_identifier' =>
array (size=1)
...
public '__isInitialized__' => boolean true
private 'Lenstrt' (Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoSensTrt) =>
object(Doctrine\ORM\PersistentCollection)[1343]
...
private 'sens_id' (Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoSensTrt) => int 3
private 'sens_nom' (Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoSensTrt) => string 'Sortant' (length=7)
private 'enstrt_id' => int 39
private 'enstrt_nom' => string 'test_mbo' (length=8)
private 'enstrt_code' => string 'TEST_MBO' (length=8)
J'arrive à récupérer les valeurs de enstrt_id, enstrt_nom et enstrt_code , tout ce qui est lesens mais pas ce qu'il y a dans uprocenstrt . Lorsque je fais un dump, il me répond :
CRITICAL - Twig_Error_Runtime: Method "uprocenstrt" for object "Intranet\ProProductionBundle\Modules\StoSuiviStocksBundle\Entity\StoEnsTrt" does not exist in "StoSuiviStocksBundle:EnsTrt:view.html.twig" at line 33 (uncaught exception) at C:\Developpement\wamp\www\Intranet_tronc\app\cache\dev\classes.php line 9445
Voici ce que j'ai mis dans le TWIG :
{% for enstrtuproc in tenstrtuproc %}
{{dump(enstrtuproc.uprocenstrt)}}
{% endfor %}
Pouvez-vous me dire comment je parcours l'objet uprocenstrt ?
Merci d'avance.