php - how to convert object to array Symfony2 -


i have object named property, how can convert array

/**  * @route("/property/{id}/pictures/download_all", name="property_zip_files_and_download", methods={"get"})       */ public function zipfilesanddownloadaction(property $property) {     $pictures = $property->pictures; $compresspath = $this->get('some_service.property.picture_compress')->compress($pictures); //some code download... .... } 

how can convert pictures array , pass service? can please me out here

what pictures?

in simple cases can use (array) $pictures.

also, can use serializer normalizers

if variable iterator (arraycollection or persistentcollection example) , service method has array typehinting, can convert simple array iterator_to_array function.

try:

$compresspath = $this->get('some_service.property.picture_compress')->compress(iterator_to_array($pictures)); 

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -