Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Symfony 4中正确配置Gedmo Sluggable?_Php_Symfony_Doctrine Orm_Symfony4_Doctrine Extensions - Fatal编程技术网

Php 如何在Symfony 4中正确配置Gedmo Sluggable?

Php 如何在Symfony 4中正确配置Gedmo Sluggable?,php,symfony,doctrine-orm,symfony4,doctrine-extensions,Php,Symfony,Doctrine Orm,Symfony4,Doctrine Extensions,我尝试在Symfony 4应用程序中正确配置Gedmo Sluggable,但失败了。问题是:它不起作用。任何slaggable列都不会被识别为slaggable,并在持久化后保持为空 composer.json: "gedmo/doctrine-extensions": "^2.4", services.yml: services: gedmo.listener.sluggable: class: Gedmo\Sluggable\SluggableListener

我尝试在Symfony 4应用程序中正确配置Gedmo Sluggable,但失败了。问题是:它不起作用。任何slaggable列都不会被识别为slaggable,并在持久化后保持为空

composer.json:

"gedmo/doctrine-extensions": "^2.4",
services.yml:

services:
    gedmo.listener.sluggable:
        class: Gedmo\Sluggable\SluggableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default, priority: 1 }
        calls:
            - [ setAnnotationReader, [ '@annotation_reader' ] ]
实体
Faculty.orm.yml

AppBundle\Entity\Faculty:
    type: entity
    table: faculty
    repositoryClass: AppBundle\Repository\FacultyRepository
    id:
      id:
        type: bigint
        generator:
          strategy: AUTO
    fields:
      name:
        type: string
        column: name
        nullable: false
        length: 128
      slug:
        type: string
        length: 128
        gedmo:
          slug:
            separator: _
            style: camel
            updatable: false
            fields:
              - name
    uniqueConstraints:
        idx_name:
          columns: [ name ]
        idx_slug:
          columns: [ slug ]
但是,当我持久化一个实体时,slug将保持为空:

    $faculty = new Faculty();
    $faculty->setName('foobar');

    $this->entityManager->persist($faculty);
    $this->entityManager->flush();
我错过什么了吗


我还试用了下面的StofOctrineExtensionsBundle。没有任何运气。Sluggable侦听器未被触发。

[setAnnotationReader,['@annotation\u reader']]
-这不是全部yaml吗?这是否仅适用于新实体?或者当您编辑一个实体时?
[setAnnotationReader,['@annotation\u reader']]
-不是所有这些都是yaml吗?这种情况仅适用于新实体吗?或者在编辑实体时也可以使用?