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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -