Vichuploaderbundle: マッピングが見つかりません、フィールドのマッピングが見つかりません

作成日 2017年09月15日  ·  6コメント  ·  ソース: dustin10/VichUploaderBundle

config.yml 
vich_uploader:
    db_driver: orm
    mappings:
        team_image:
            uri_prefix:         /uploads/logos
            upload_destination: '%kernel.root_dir%/../web/uploads/logos'
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true

エンティティ

<?php


namespace AppBundle\Entity;

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



/**
 * @ORM\Entity
 * @Vich\Uploadable
 * @ORM\Table(name="team")
 */
class Team
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    // ..... other fields

    /**
     * NOTE: This is not a mapped field of entity metadata, just a simple property.
     *
     * @Vich\UploadableField(mapping="team_image", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName")
     *
     * <strong i="8">@var</strong> File
     */
    private $imageFile;

    /**
     * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File")
     *
     * <strong i="9">@var</strong> EmbeddedFile
     */
    private $image;

    /**
     * @ORM\Column(type="datetime")
     *
     * <strong i="10">@var</strong> \DateTime
     */
    private $updatedAt;

    /**
     * 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.
     *
     * <strong i="11">@param</strong> File|UploadedFile $image
     */
    public function setImageFile(File $image = null)
    {
        $this->imageFile = $image;

        if ($image) {
            // 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();
        }
    }

    /**
     * <strong i="12">@return</strong> File|null
     */
    public function getImageFile()
    {
        return $this->imageFile;
    }

    /**
     * <strong i="13">@param</strong> EmbeddedFile $image
     */
    public function setImage(EmbeddedFile $image)
    {
        $this->image = $image;
    }

    /**
     * <strong i="14">@return</strong> EmbeddedFile
     */
    public function getImage()
    {
        return $this->image;
    }


}

マッピングが見つからない理由がわかりません。助けが必要です。

Support

最も参考になるコメント

同じエラーでここに来る人のために:

フォームでは、使用する必要があります$imageFile代わりのプロパティ$image一つ。

全てのコメント6件

通常のエンティティをこれと混合することはできません??? 写真のエンティティだけが必要ですか?

解決するフォームで問題を見つけます

同じエラーでここに来る人のために:

フォームでは、使用する必要があります$imageFile代わりのプロパティ$image一つ。

@diegocastro
同じ問題が発生しています
正確な解決策は何ですか? easyAdminBundleを使用しています。

ありがとう

@ stef59100 EasyAdminBundleを使用していないので、そこでお手伝いすることはできません。 フォームを定義する場所はありますか? その場合、フォームを$imageプロパティにマップしないでください。代わりに、 $imageFile使用してください。

EAで@diegocastroと同じ問題が発生しましたが、問題は無関係@Vich\Uploadable 。エンティティファイルの先頭にある

このページは役に立ちましたか?
0 / 5 - 0 評価