Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-filter doesn't work with vichUploaderField #22

Open
Koronos opened this issue Mar 3, 2021 · 1 comment
Open

Multi-filter doesn't work with vichUploaderField #22

Koronos opened this issue Mar 3, 2021 · 1 comment
Labels

Comments

@Koronos
Copy link

Koronos commented Mar 3, 2021

Using the next example:

	/**
	 * @Vich\UploadableField(mapping="files", fileNameProperty="fileName", size="fileSize")
	 * @Serializer\Exclude()
	 *
	 * @var \Symfony\Component\HttpFoundation\File\File|null
	 */
    private $file;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
	 * @Serializer\SerializedName("file")
	 *
	 * @LiipImagineSerializableField(filter={"api_img","api_thumb"}, vichUploaderField="file")
     */
    private $fileName;

When I use a single filter it works perfectly:

@LiipImagineSerializableField("api_img", vichUploaderField="file")

But I use more than 1 filter, I got an Array to string conversion error in JMS

at K:\wamp64\www\refaccionariaCentro\vendor\jms\serializer\src\GraphNavigator\SerializationGraphNavigator.php:144
at JMS\Serializer\GraphNavigator\SerializationGraphNavigator->accept(array('api_img' => 'http://localhost:8000/media/cache/resolve/api_img/files/153825169-150412593593858-1896732942807405473-n-603ffab9beae2505028842.png', 'api_thumb' => 'http://localhost:8000/media/cache/resolve/api_thumb/files/153825169-150412593593858-1896732942807405473-n-603ffab9beae2505028842.png'), array('name' => 'string', 'params' => array()))

For the moment it can be fixed adding the @Serializer\Type("array") annotation to the field when are used more than 1 filter. The strange is that in a string field, is not necessary.

Suggestion:

The limp annotation should set is as array when is added more than 1 filter as it does when is a string property. Or almost should be added this info to the docs.

Regards.

@Bukashk0zzz
Copy link
Owner

Thanks for the issue with the detailed description.
Not sure that I will have time to fix this soon, but pull requests are welcome.

@Bukashk0zzz Bukashk0zzz added the bug label Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants