-
Notifications
You must be signed in to change notification settings - Fork 3
Internals
The core classes involved with auditing are registered at bootstrap from the Module.
public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getParam('application')->getServiceManager();
$serviceManager->get('ZF\Doctrine\Audit\Loader\AuditAutoloader')->register();
$serviceManager->get('ZF\Doctrine\Audit\Mapping\Driver\AuditDriver')->register();
$serviceManager->get('ZF\Doctrine\Audit\EventListener\LogRevision')->register();
}
This class dynamically creates PHP classes for Entities in the audit object manager. Because every entity managed by an object manager needs an object from which to be managed, this class creates those entity classes as needed. Uses a use Zend\Loader\StandardAutoloader
.
This is a driver for Doctrine which is registered at run time to the audit object manager. This driver registers an XML driver for the concrete zf-doctrine-audit classes and registers itself to map the metadata for the entities created by the AuditAutoloader.
The workhorse for auditing. This listens to onFlush
and postFlush
on the target object manager events and creates the audit record for them. Because of how this listens it cannot exist on the target object manager and this is why zf-doctrine-audit requires a separate object manager.
The audit object manager is no different than a standard object manager. For all intents and purposes the audit object manager simply manages a different set of entities than those being audited. The LogRevision ties them together. This approach provides you with full access to Doctrine for query building and everything else. You could even write event an EventListener for the audit object manager.
For the [Audit Schema](Audit Schema) all the classes are concrete and no dynamic relations are created. The entity class definitions and XML metadata are included.
This class is used for all AuditAutoloader created classes as an abstract to inherit from.
In order to keep all the audit initializers out of the core service_manager config the classes used in zf-doctrine-audit use a single abstract factory. This abstract factory is in the core service_manager.
There is one Initializer registered in the service_manager: [Revision Comment](Revision Comment).
zf-doctrine-audit © 2016 API Skeletons. Released under the MIT license.