|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file contains only the DisabledToolSubscriber class. |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace AppBundle\EventSubscriber; |
|
7
|
|
|
|
|
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
9
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
10
|
|
|
use Symfony\Component\HttpKernel\Event\FilterControllerEvent; |
|
11
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
12
|
|
|
use Symfony\Component\HttpKernel\KernelEvents; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* A DisabledToolSubscriber checks to see |
|
16
|
|
|
*/ |
|
17
|
|
|
class DisabledToolSubscriber implements EventSubscriberInterface |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
/** @var ContainerInterface The DI container. */ |
|
21
|
|
|
protected $container; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Save the container for later use. |
|
25
|
|
|
* @param Container $container The DI container. |
|
|
|
|
|
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct(ContainerInterface $container) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->container = $container; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Register our interest in the kernel.controller event. |
|
34
|
|
|
* @return string[] |
|
35
|
|
|
*/ |
|
36
|
|
|
public static function getSubscribedEvents() |
|
37
|
|
|
{ |
|
38
|
|
|
return [ |
|
39
|
|
|
KernelEvents::CONTROLLER => 'onKernelController', |
|
40
|
|
|
]; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Check to see if the current tool is enabled. |
|
45
|
|
|
* @param FilterControllerEvent $event The event. |
|
46
|
|
|
* @throws NotFoundHttpException If the tool is not enabled. |
|
47
|
|
|
*/ |
|
48
|
|
|
public function onKernelController(FilterControllerEvent $event) |
|
49
|
|
|
{ |
|
50
|
|
|
$controller = $event->getController(); |
|
51
|
|
|
if (method_exists($controller[0], 'getToolShortname')) { |
|
52
|
|
|
$tool = $controller[0]->getToolShortname(); |
|
53
|
|
|
if (!$this->container->getParameter("enable.$tool")) { |
|
54
|
|
|
throw new NotFoundHttpException('This tool is disabled'); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths