Sonata Admin + Vich Upload 加载时注入无效

Sonata Admin + Vich Upload inject on load not working

我正在使用 vich upload with sonata admin & 我可以上传和删除文件 我的问题是我无法获取上传的文件信息

我使用 vich 上传器配置 "inject_on_load" 为真

vich_uploader:
    db_driver: orm # or mongodb or propel or phpcr
    mappings:
        small_image:
            uri_prefix:         /uploads/images/small
            upload_destination: %kernel.root_dir%/../web/uploads/images/small
            namer:              vich_uploader.namer_uniqid
            inject_on_load:     true
            delete_on_update:   true
            delete_on_remove:   true

现在,当我将我的对象转储到控制器中时,我得到了带有 File Inejcted Proprieties 的对象

Movie {#679 ▼
 -id: 7
 -featureImageFile: -featureImageFile: File {#771 ▼
    path: "C:\wamp/../web/uploads/images/feature"
    filename: "56cd61b786c57.jpg"
    basename: "56cd61b786c57.jpg"
    pathname: "C:\wamp\www\/uploads/images/featurecd61b786c57.jpg"
    extension: "jpg"
    realPath: "C:\wamp\www\uploads\images\featurecd61b786c57.jpg"
    aTime: 2016-02-24 08:54:30
    mTime: 2016-02-24 08:54:30
    cTime: 2016-02-24 08:54:30
    inode: 0
    size: 173519
    perms: 0100666
    owner: 0
    group: 0
    type: "file"
    writable: true
    readable: true
    executable: false
    file: true
    dir: false
    link: false
    linkTarget: "C:\wamp\...\images\featurecd61b786c57.jpg"
   }
 -featureImageName: "56cd61b786c57.jpg"
  #regions: PersistentCollection {#717 ▶}
  #genre: Genre {#739 ▶}
  #language: Language {#745 ▶}
} 

但是我正在奏鸣曲 postUpdate(movie) 保存挂钩中加载文件我没有得到关于文件的任何信息

public function postUpdate($movie){
    dump($movie); exit;
}

我得到了这个结果

Movie {#679 ▼
 -id: 7
 -featureImageFile: null
 -featureImageName: "56cd61b786c57.jpg"
  #regions: PersistentCollection {#717 ▶}
  #genre: Genre {#739 ▶}
  #language: Language {#745 ▶}
} 

这是我的电影实体 class

<?php

namespace Application\NS\AdminBundle\Entity;

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


/**
 * Movie
 *
 * @ORM\Table(name="movie")
 * @ORM\Entity(repositoryClass="Application\NS\AdminBundle\Repository\MovieRepository")
 * @Vich\Uploadable
 */
class Movie
{



    /**
     * @Vich\UploadableField(mapping="feature_image", fileNameProperty="featureImageName")
     * @var File
     */
    private $featureImageFile;

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

    /**
     * Set featureImageName
     * @param string $featureImageName
     * @return object
     */
    public function setFeatureImageName($featureImageName) {
        $this->featureImageName = $featureImageName;
        return $this;
    }

    /**
     * Get featureImageName
     * @return string
     */
    public function getFeatureImageName(){
        return $this->featureImageName;
    }

}

这是我的管理员 class

/**
 * @param FormMapper $formMapper
 */
protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
     ->add('featureImageFile', 'vich_image', array( 'required' => false, 'allow_delete'  => true, 'download_link' => false))
}                

我缺少什么有人可以帮忙吗? 有没有其他方法可以将上传的文件信息注入实体对象

我们需要手动刷新 doctrine 对象以加载更新的属性(vich 上传器通过事件将文件信息注入对象 属性)

 $this->getContainer()->get('doctrine.orm.entity_manager')->refresh($movie);