ProtectedReferencesDoctrineSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 3 1
A __construct() 0 2 1
A preRemove() 0 2 1
1
<?php
2
3
/*
4
 * This file is part of the OneGuard DynamicConfigurationBundle.
5
 *
6
 * (c) OneGuard <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace OneGuard\Bundle\DynamicConfigurationBundle\Listener;
13
14
use Doctrine\Common\EventSubscriber;
15
use Doctrine\ORM\Event\LifecycleEventArgs;
16
use OneGuard\Bundle\DynamicConfigurationBundle\Exception\ProtectedReferenceException;
17
use OneGuard\Bundle\DynamicConfigurationBundle\ProtectedReferencesChecker;
18
19
class ProtectedReferencesDoctrineSubscriber implements EventSubscriber {
20
	/**
21
	 * @var ProtectedReferencesChecker
22
	 */
23
	private $checker;
24
25
	public function __construct(ProtectedReferencesChecker $checker) {
26
		$this->checker = $checker;
27
	}
28
29
	public function getSubscribedEvents() {
30
		return [
31
			'preRemove'
32
		];
33
	}
34
35
	/**
36
	 * @param LifecycleEventArgs $args
37
	 * @throws ProtectedReferenceException
38
	 * @throws \Doctrine\ORM\NoResultException
39
	 * @throws \Doctrine\ORM\NonUniqueResultException
40
	 */
41
	public function preRemove(LifecycleEventArgs $args) {
42
		$this->checker->checkReferenceForProtection($args->getObject());
43
	}
44
}
45