You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've looked everywhere but unfortunately I can't find my answer. I tried to debug it myself but without success.
I can write correctly in the db and in my ObjectStorage
I've done the classical way (not my first time) to get FlySystem and VichUploader working. I've come to notice that when I request reading entity, VichUploader is not called at all. As a result, I get the following error:
{"message": "Cannot assign string to property App\Entity\Shops::$imageFile of type ?Symfony\Component\HttpFoundation\\File"}
Thank you in advance for an indication or look I attach my files below.
Best regards,
Nestate
Support Question
//Entity/shops
<?php
namespace App\Entity;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\ShopsRepository;
use Symfony\Component\HttpFoundation\File\File;
#[ORM\Entity(repositoryClass: ShopsRepository::class)]
#[Vich\Uploadable]
class Shops implements EntityFilesInterface
{
// Some var
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['get:shop', 'is:file'])]
#[Vich\UploadableField(mapping: 'shopImage', fileNameProperty: 'imageName', size: 'imageSize')]
private ?File $imageFile = null;
//Other var and function
// Image Functions
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
if ($imageFile instanceof File) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
$this->imageFile = $imageFile;
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageName(?string $imageName): void
{
$this->imageName = $imageName;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageSize(?int $imageSize): void
{
$this->imageSize = $imageSize;
}
public function getImageSize(): ?int
{
return $this->imageSize;
}
I got the error I've written on top of my message like the bundle is not used for getting from DB I've used them in two projects before this one and I don't understand why this time it doesn't work
The text was updated successfully, but these errors were encountered:
Well, I'm still trying to figure out where the problem is coming from and I'm trying to fix it. It seems that the problem comes from BaseListener to the function getUploadableFields it is not triggered. On my other projects it is. I don't know if I'm on the right track.
I've looked everywhere but unfortunately I can't find my answer. I tried to debug it myself but without success.
I can write correctly in the db and in my ObjectStorage
I've done the classical way (not my first time) to get FlySystem and VichUploader working. I've come to notice that when I request reading entity, VichUploader is not called at all. As a result, I get the following error:
{"message": "Cannot assign string to property App\Entity\Shops::$imageFile of type ?Symfony\Component\HttpFoundation\\File"}
Thank you in advance for an indication or look I attach my files below.
Best regards,
Nestate
Support Question
My vich_uploader configuration file:
And in a controller as i do:
I got the error I've written on top of my message like the bundle is not used for getting from DB I've used them in two projects before this one and I don't understand why this time it doesn't work
The text was updated successfully, but these errors were encountered: