小编Nic*_*cki的帖子

Symfony VichUploaderBundle:无法生成文件名

我正在使用VichUploader在symfony项目中上传文件.在我使用的配置中(从文档中复制):

service: vich_uploader.namer_property
options: { property: 'slug'}
Run Code Online (Sandbox Code Playgroud)

在我的实体中,我使用Gedmo/Sluggable自动生成slu ::

/**
 * @Gedmo\Slug(fields={"title"}, updatable=false)
 * @ORM\Column(type="string", length=100, nullable=false)
 */
protected $slug;
Run Code Online (Sandbox Code Playgroud)

但是当试图保存实体时,我得到以下错误500:

无法生成文件名:属性slug为空.

如果我将属性设置为'title'就可以了.我是否忘记了配置参数或其他什么来使它与Gedmo slug一起工作?

php symfony vichuploaderbundle

6
推荐指数
1
解决办法
891
查看次数

Symfony/Doctrine:addJoinedEntityResult如何为一对多关系工作?

我有以下问题.我想这是误会.但谷歌搜索几个小时后没有找到解决方案我在这里发布.

我在Doctrine中有一个原生查询:

$rsm = new ResultSetMapping;
        $rsm->addEntityResult('Acme\CommentBundle\Entity\Comment', 'c');
        $rsm->addFieldResult('c', 'comment_id', 'id');
        $rsm->addFieldResult('c', 'slug', 'slug');
        $rsm->addFieldResult('c', 'comment', 'comment');
        $rsm->addFieldResult('c', 'created', 'created');
        $rsm->addJoinedEntityResult('Acme\AccountBundle\Entity\Worker', 'w', 'c', 'komments');
        $rsm->addFieldResult('w', 'worker_id', 'id');
        $rsm->addFieldResult('w', 'worker_name', 'name');
        $rsm->addJoinedEntityResult('Acme\CommentBundle\Entity\Document', 'd', 'c', 'documents');
        $rsm->addFieldResult('d', 'document_id', 'id');
        $rsm->addFieldResult('d', 'document_name', 'name');

        return $this->getEntityManager()
            ->createNativeQuery('SELECT t.id, c.id AS comment_id, c.slug, c.created, c.comment, c.worker_id AS comment_worker_id, c.created AS comment_created, d.id AS document_id, d.name AS document_name, w.id AS worker_id, w.name AS worker_name
            FROM comment_thread t
            INNER JOIN project p ON p.comment_thread_id = t.id
            LEFT …
Run Code Online (Sandbox Code Playgroud)

doctrine native symfony

5
推荐指数
1
解决办法
1972
查看次数

标签 统计

symfony ×2

doctrine ×1

native ×1

php ×1

vichuploaderbundle ×1