Symfony 4 Easy Admin и Vich Uploader Bundle Ошибка

Я использую пакет vich-uploader с easy-admin с помощью symfony4.
После установки я получаю эту ошибку при попытке удалить или обновить объект

Ожидаемый аргумент типа «string», «NULL», заданный в пути к свойству «imageName».

Конфигурация приложения наиболее проста в этом обычном случае.
Шахта Тестирование объекта:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;


/**
* @ORM\Entity(repositoryClass="App\Repository\TestRepository")
* @Vich\Uploadable
*/
class Test
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;

/**
* @ORM\Column(type="string", length=255)
*/
private $imageName;

/**
* @Vich\UploadableField(mapping="test_images", fileNameProperty="imageName")
* @var File
*/
private $imageFile;

/**
* @ORM\Column(type="datetime")
* @var \DateTime
*/
private $updatedAt;


public function getId()
{
return $this->id;
}

public function getImageName()
{
return $this->imageName;
}

public function setImageName(string $image)
{
$this->imageName = $image;

return $this;
}

public function setImageFile(File $image = null)
{
$this->imageFile = $image;

if ($image) {
$this->updatedAt = new \DateTime('now');
}
}

public function getImageFile()
{
return $this->imageFile;
}


public function getUpdatedAt()
{
return $this->updatedAt;
}

public function setUpdatedAt(\DateTime $datetime)
{
$this->updatedAt = $datetime;

return $this;
}
}

Мой простой админ конфиг yaml

easy_admin:
entities:
Test:
class: App\Entity\Test
form:
fields:
- { property: 'imageFile', type: 'vich_image' }
# ...
list:
fields:
- { property: 'image', type: 'image', base_path: '%app.path.banner_images%' }
# ...
show:
fields:
- { property: 'image', type: 'image', base_path: '%app.path.banner_images%' }

1

Решение

Попробуй с

public function setImageName(?string $image)
{
$this->imageName = $image;

return $this;
}
3

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector