Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Doctrine entity persistent collection data values with symfony

What is best way to convert Doctrine entity persistent collection to array with symfony 2 ? I want to get the values and later by using that array value, need to get the second entity values which dependent on first entity using form event listener.

like image 242
Abha Rana Avatar asked Mar 12 '19 12:03

Abha Rana


2 Answers

If I understand your question correctly, this helps you:

$arrayValues = $persistentCollection->getValues();

like image 65
Evgeny Ruban Avatar answered Sep 23 '22 14:09

Evgeny Ruban


$yourCollection->unwrap()->toArray();

That should give you the content of your collection as an array()

like image 42
Yoann MIR Avatar answered Sep 22 '22 14:09

Yoann MIR