Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

add support for SoftDeleteable #123

Merged
merged 3 commits into from

2 participants

@igorw

No description provided.

@stof
Owner

@igorw can you update the doc too ? It needs to explain how to add the filter

@igorw

Done.

Resources/doc/index.rst
((9 lines not shown))
+
+::
+
+ # app/config/config.yml
+ doctrine:
+ orm:
+ entity_managers:
+ default:
+ filters:
+ softdeleteable:
+ class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
+ enabled: true
+
+.. note::
+
+ If you are using the short syntax for the ORM configuration, the `mappings`
@stof Owner
stof added a note

filters, not mappings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Resources/doc/index.rst
((14 lines not shown))
+ orm:
+ entity_managers:
+ default:
+ filters:
+ softdeleteable:
+ class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
+ enabled: true
+
+.. note::
+
+ If you are using the short syntax for the ORM configuration, the `mappings`
+ key is directly under `orm:`
+
+.. note::
+
+ If you are using several entity managers, take care to register the entities
@stof Owner
stof added a note

this is about registering filters, not entities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stof stof merged commit 59be31e into stof:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
5 DependencyInjection/Configuration.php
@@ -50,6 +50,7 @@ private function getVendorNode($name)
->scalarNode('tree')->defaultFalse()->end()
->scalarNode('loggable')->defaultFalse()->end()
->scalarNode('sortable')->defaultFalse()->end()
+ ->scalarNode('softdeleteable')->defaultFalse()->end()
->end()
->end()
;
@@ -89,6 +90,10 @@ private function getClassNode()
->cannotBeEmpty()
->defaultValue('Gedmo\\Sortable\\SortableListener')
->end()
+ ->scalarNode('softdeleteable')
+ ->cannotBeEmpty()
+ ->defaultValue('Gedmo\\SoftDeleteable\\SoftDeleteableListener')
+ ->end()
->end()
;
View
5 Resources/config/listeners.xml
@@ -49,6 +49,11 @@
<argument type="service" id="annotation_reader" />
</call>
</service>
+ <service id="stof_doctrine_extensions.listener.softdeleteable" class="%stof_doctrine_extensions.listener.softdeleteable.class%" public="false">
+ <call method="setAnnotationReader">
+ <argument type="service" id="annotation_reader" />
+ </call>
+ </service>
<!-- Symfony listeners -->
<service id="stof_doctrine_extensions.event_listener.locale" class="%stof_doctrine_extensions.event_listener.locale.class%" public="false">
View
35 Resources/doc/index.rst
@@ -141,6 +141,40 @@ to register their mapping in Doctrine when you want to use them.
The mapping for MongoDB is similar. The ODM documents are in the `Document`
subnamespace of each extension instead of `Entity`.
+Enable the softdeleteable filter
+--------------------------------
+
+If you want to use the SoftDeleteable behavior, you have to enable the
+doctrine filter.
+
+::
+
+ # app/config/config.yml
+ doctrine:
+ orm:
+ entity_managers:
+ default:
+ filters:
+ softdeleteable:
+ class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
+ enabled: true
+
+.. note::
+
+ If you are using the short syntax for the ORM configuration, the `filters`
+ key is directly under `orm:`
+
+.. note::
+
+ If you are using several entity managers, take care to register the filter
+ for the right ones.
+
+To disable the behaviour, e.g. for admin users who may see deleted items,
+disable the filter. Here is an example::
+
+ $filters = $em->getFilters();
+ $filters->disable('softdeleteable');
+
Configure the bundle
====================
@@ -246,6 +280,7 @@ in YAML::
sluggable: ~
translatable: ~
loggable: ~
+ softdeleteable: ~
or in XML::
Something went wrong with that request. Please try again.