-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIbrowsLoggableBundle.php
39 lines (34 loc) · 1.19 KB
/
IbrowsLoggableBundle.php
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
<?php
namespace Ibrows\LoggableBundle;
use Ibrows\LoggableBundle\DependencyInjection\CompilerPass;
use Ibrows\LoggableBundle\Listener\LoggableListener;
use Symfony\Bridge\Doctrine\ContainerAwareEventManager;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class IbrowsLoggableBundle extends Bundle
{
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new CompilerPass());
}
/**
* LoggableListener as last listener aka shizzle my nizze
*/
public function boot()
{
//shizzle my nizzle
$eventManager = $this->container->get('doctrine')->getManager()->getEventManager();
/* @var ContainerAwareEventManager $eventManager */
$allListeners = $eventManager->getListeners('onFlush');
foreach($allListeners as $listener){
if($listener instanceof LoggableListener){
$eventManager->removeEventListener('onFlush', $listener);
$eventManager->addEventListener('onFlush', $listener);
}
}
}
}