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
Post a Comment