Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #97 from franek/256af41bd071587cac49c9303903f8445b…

…f2fb87

 Allow to disable audit for certain entity
  • Loading branch information...
commit c1b6fef7a5f449bdf8966da50683924253986d68 2 parents f24eca4 + 2d9f966
@rande rande authored
View
15 DependencyInjection/Compiler/AddAuditEntityCompilerPass.php 100644 → 100755
@@ -32,7 +32,7 @@ public function process(ContainerBuilder $container)
return;
}
- $autitedEntities = $container->getParameter('simplethings.entityaudit.audited_entities');
+ $auditedEntities = $container->getParameter('simplethings.entityaudit.audited_entities');
foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
@@ -40,15 +40,18 @@ public function process(ContainerBuilder $container)
continue;
}
- $definition = $container->getDefinition($id);
+ if (isset($attributes[0]['audit']) && $attributes[0]['audit'] == false) {
+ continue;
+ }
- $autitedEntities[] = $this->getModelName($container, $definition->getArgument(1));
+ $definition = $container->getDefinition($id);
+ $auditedEntities[] = $this->getModelName($container, $definition->getArgument(1));
}
- $autitedEntities = array_unique($autitedEntities);
+ $auditedEntities = array_unique($auditedEntities);
- $container->setParameter('simplethings.entityaudit.audited_entities', $autitedEntities);
- $container->getDefinition('sonata.admin.audit.manager')->addMethodCall('setReader', array('sonata.admin.audit.orm.reader', $autitedEntities));
+ $container->setParameter('simplethings.entityaudit.audited_entities', $auditedEntities);
+ $container->getDefinition('sonata.admin.audit.manager')->addMethodCall('setReader', array('sonata.admin.audit.orm.reader', $auditedEntities));
}
/**
View
15 Resources/doc/reference/audit.rst 100644 → 100755
@@ -28,7 +28,20 @@ DDL statements for your audited entities.
Configuration
-------------
-If the ``EntityAuditBundle`` is enabled, then all entities managed by the ``DoctrineORMAdminBundle`` will be autited.
+If the ``EntityAuditBundle`` is enabled, then all entities managed by the ``DoctrineORMAdminBundle`` will be audited.
+
+It is possible to disable an entity to be audited with the attribute audit="false" in services.xml
+For instance :
+.. code-block:: xml
+
+ <service id="tutorial.blog.admin.post" class="Tutorial\BlogBundle\Admin\PostAdmin">
+ <tag name="sonata.admin" manager_type="orm" audit="false" group="tutorial_blog" label="post"/>
+
+ <argument/>
+ <argument>Tutorial\BlogBundle\Entity\Post</argument>
+ <argument>TutorialBlogBundle:PostAdmin</argument>
+ </service>
+
Usage
-----
Please sign in to comment.
Something went wrong with that request. Please try again.