gpt4 book ai didi

symfony - VichUploaderBundle - 命名者 : Parent definition does not exist

转载 作者:行者123 更新时间:2023-12-02 17:11:06 26 4
gpt4 key购买 nike

config.yml

vich_uploader:
db_driver: orm
mappings:
media_image:
uri_prefix: '%uploads_dir%'
upload_destination: '%kernel.root_dir%/../web/uploads/images'
namer: Vich\UploaderBundle\Naming\OrignameNamer

实体:

/**
* Media
* @Vich\Uploadable
* @ORM\Table(name="medias")
* @ORM\Entity(repositoryClass="AppBundle\Repository\MediaRepository")
*/
class Media
{

use TimestampableEntity;

/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

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

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

/**
* @var string
*
* @ORM\Column(name="mime_type", type="string", length=20, nullable=true)
*/
private $mimeType;

/**
* @var string
*
* @ORM\Column(name="size", type="integer", nullable=true)
*/
private $size;

当我启用 namer 时,我收到此错误:

enter image description here

有什么想法吗?

最佳答案

(自定义)命名器应注册为服务并通过其服务名称引用。

您可以在下面的示例中看到默认(长)配置以及 VichUploaderBundle 提供的命名服务列表:

vich_uploader:   
# [..]
mappings:
product_image_file:
# [..]
namer:
# one of: vich_uploader.namer_{uniqid,origname,property,hash}
service: vich_uploader.namer_origname
<小时/>

作为引用,以下是命令 bin/console debug:container 列出的所有命名服务:

vich_uploader.namer_base64                Vich\UploaderBundle\Naming\Base64Namer
vich_uploader.namer_directory_property Vich\UploaderBundle\Naming\PropertyDirectoryNamer
vich_uploader.namer_hash Vich\UploaderBundle\Naming\HashNamer
vich_uploader.namer_origname Vich\UploaderBundle\Naming\OrignameNamer
vich_uploader.namer_property Vich\UploaderBundle\Naming\PropertyNamer
vich_uploader.namer_uniqid Vich\UploaderBundle\Naming\niqidNamer

关于symfony - VichUploaderBundle - 命名者 : Parent definition does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48441537/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com