forked from sonata-project/EntityAuditBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuditManager.php
More file actions
49 lines (40 loc) · 1.16 KB
/
AuditManager.php
File metadata and controls
49 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace SimpleThings\EntityAudit;
use Doctrine\Common\EventManager;
use Doctrine\ORM\EntityManager;
use SimpleThings\EntityAudit\EventListener\CreateSchemaListener;
use SimpleThings\EntityAudit\EventListener\LogRevisionsListener;
/**
* Audit Manager grants access to metadata and configuration
* and has a factory method for audit queries.
*/
class AuditManager
{
private $config;
private $metadataFactory;
/**
* @param AuditConfiguration $config
*/
public function __construct(AuditConfiguration $config)
{
$this->config = $config;
$this->metadataFactory = $config->createMetadataFactory();
}
public function getMetadataFactory()
{
return $this->metadataFactory;
}
public function getConfiguration()
{
return $this->config;
}
public function createAuditReader(EntityManager $em)
{
return new AuditReader($em, $this->config, $this->metadataFactory);
}
public function registerEvents(EventManager $evm)
{
$evm->addEventSubscriber(new CreateSchemaListener($this));
$evm->addEventSubscriber(new LogRevisionsListener($this));
}
}