I have a ManyToMany relation. It return a collection type which I have in $collectionProductAutoclave. When I dump it, I get my objects, so no problem. However, some of them are proxies, and I can't manage to get value from it, only true boolean. I want to compare id from this object with another. here the dump of my var:
dump($collectionProductAutoclave);
^ array:2 [▼
0 => Proxies\__CG__\App\Entity\Product {#1423 ▼
+__isInitialized__: true
-id: 1
-titre: "dfg"
-diametreTube: "45"
-workCharge: 4
-tension: 45
-montageCharge: 1
-stockFuseaux: false
-type: "dfg"
-commandes: Doctrine\ORM\PersistentCollection {#1547 ▶}
-materiau: Proxies\__CG__\App\Entity\Materiau {#1565 ▶}
-papier: 789
-diametreFuseaux: 45
-Intensity: 456
-HauteurMax: "465"
-HauteurStandard: "465"
-autoclaves: Doctrine\ORM\PersistentCollection {#1564 ▶}
…2
}
1 => App\Entity\Product {#1318 ▼
-id: 2
-titre: "dsfgzerezer"
-diametreTube: "45"
-workCharge: 1
-tension: 456
-montageCharge: 2
-stockFuseaux: false
-type: "zer"
-commandes: Doctrine\ORM\PersistentCollection {#1455 ▶}
-materiau: Proxies\__CG__\App\Entity\Materiau {#1565 ▶ …2}
-papier: 45
-diametreFuseaux: 21
-Intensity: 987
-HauteurMax: "123"
-HauteurStandard: "123"
-autoclaves: Doctrine\ORM\PersistentCollection {#1566 ▶}
}
]
dump($collectionProductAutoclave->getValues());
^ array:2 [▼
0 => true
1 => App\Entity\Product {#1318 ▶}
]
I only saw very old answer to this kind of problem.
I figured out ! When testing my values, i got true bool on proxies objects if i used a while loop. But using a foreach $vars as var loop prevented doctrine to make proxies and made me able to get values from this.