-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathTraceableMap.php
More file actions
48 lines (37 loc) · 1.24 KB
/
TraceableMap.php
File metadata and controls
48 lines (37 loc) · 1.24 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
<?php
namespace JMS\DebuggingBundle\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Http\FirewallMapInterface;
class TraceableMap implements FirewallMapInterface
{
private $container;
private $map;
private $lastTrace;
public function __construct(ContainerInterface $container, array $map)
{
$this->container = $container;
$this->map = $map;
}
public function getListeners(Request $request)
{
$trace = array();
foreach ($this->map as $contextId => $requestMatcher) {
$matches = null === $requestMatcher || $requestMatcher->matches($request);
$trace[substr($contextId, strrpos($contextId, '.') + 1)] = array(
'matches' => $matches,
'reason' => !$matches ? $requestMatcher->getLastMatch() : null,
);
if ($matches) {
$this->lastTrace = $trace;
return $this->container->get($contextId)->getContext();
}
}
$this->lastTrace = $trace;
return array(array(), null);
}
public function getLastTrace()
{
return $this->lastTrace;
}
}