|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
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 Symfony\Component\Security\Acl\Domain; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\Security\Acl\Model\AuditableEntryInterface; |
|
|
15 |
use Symfony\Component\Security\Acl\Model\EntryInterface; |
|
|
16 |
use Symfony\Component\Security\Acl\Model\AuditLoggerInterface; |
|
|
17 |
|
|
|
18 |
/** |
|
|
19 |
* Base audit logger implementation |
|
|
20 |
* |
|
|
21 |
* @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
|
22 |
*/ |
|
|
23 |
abstract class AuditLogger implements AuditLoggerInterface |
|
|
24 |
{ |
|
|
25 |
/** |
|
|
26 |
* Performs some checks if logging was requested |
|
|
27 |
* |
|
|
28 |
* @param Boolean $granted |
|
|
29 |
* @param EntryInterface $ace |
|
|
30 |
* @return void |
|
|
31 |
*/ |
|
|
32 |
public function logIfNeeded($granted, EntryInterface $ace) |
|
|
33 |
{ |
|
|
34 |
if (!$ace instanceof AuditableEntryInterface) { |
|
|
35 |
return; |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
if ($granted && $ace->isAuditSuccess()) { |
|
|
39 |
$this->doLog($granted, $ace); |
|
|
40 |
} else if (!$granted && $ace->isAuditFailure()) { |
|
|
41 |
$this->doLog($granted, $ace); |
|
|
42 |
} |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
/** |
|
|
46 |
* This method is only called when logging is needed |
|
|
47 |
* |
|
|
48 |
* @param Boolean $granted |
|
|
49 |
* @param EntryInterface $ace |
|
|
50 |
* @return void |
|
|
51 |
*/ |
|
|
52 |
abstract protected function doLog($granted, EntryInterface $ace); |
|
|
53 |
} |