Listener "SoftDeleteableListener" was not added to the EventManager
Couldn't solve problem because of unclear answer.
To add softdeletable behaviour to your project add following lines to your config.yml
orm
..
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
services:
..
gedmo.listener.softdeleteable:
class: Gedmo\SoftDeleteable\SoftDeleteableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ '@annotation_reader' ] ]
Btw, more complete discussion, which helped me, can be found: https://github.com/Atlantic18/DoctrineExtensions/issues/380
See: https://github.com/stof/StofDoctrineExtensionsBundle/blob/master/Resources/doc/index.rst#activate-the-extensions-you-want
Add the following to your config.yml to activate the softdelete listener:
# app/config.yml
stof_doctrine_extensions:
default_locale: %locale%
orm:
default:
softdeleteable: true
If you are on api-platform
This is my config/packages/doctrine.yml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
server_version: '12'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
after that add the new service to config.services.yml
services:
..........
..........
gedmo.listener.softdeleteable:
class: Gedmo\SoftDeleteable\SoftDeleteableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ '@annotation_reader' ] ]
Finally add the annotation to the entity
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ApiResource()
* @ORM\Entity(repositoryClass=StoreRepository::class)
* @ORM\Table(name="trn_stores")
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
class Store ...
That's it