我尝试在我的项目上获得可慢量学说扩展。我按照在互联网上找到的设置步骤进行操作,但它似乎不起作用(@Gedmo\slug似乎没有被调用/触发(。
目的是删除帖子标题。
我在PHP 7.1上使用Symfony 3.4和Doctrine 2.3。
如果有人知道如何获得这项工作,我将不胜感激。
我在应用程序内核中添加了捆绑包 (new StofDoctrineExtensionsBundleStofDoctrineExtensionsBundle()
(
这是我的其他项目文件:
作曲家.json
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0",
"stof/doctrine-extensions-bundle": "^1.3.0",
"gedmo/doctrine-extensions": "^2.3.4"
},
app/config/config.yml
# StofDoctrineExtensionsBundle configuration
stof_doctrine_extensions:
orm:
default:
sluggable: true
src/xxx/xxxBundle/Entity/Advert.php
use GedmoMappingAnnotation as Gedmo;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineORMMapping as ORM;
* @ORMHasLifecycleCallbacks()
*/
class Advert
{
/**
* @var string
*
* @ORMColumn(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
*
* @GedmoSlug(fields={"title"})
* @ORMColumn(name="slug", type="string", length=255, unique=true, nullable=true)
*/
private $slug;
我刚刚弄清楚!
我忘了在我的捆绑包中添加该服务。
所以在我的服务.yml中,我添加了以下行:
gedmo.listener.sluggable:
class: GedmoSluggableSluggableListener
tags:
- { name: doctrine.event_subscriber, connection: pgsql }
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ]