Version 1
[yaffs-website] / web / modules / contrib / devel / webprofiler / src / RequestMatcher / WebprofilerRequestMatcher.php
1 <?php
2
3 namespace Drupal\webprofiler\RequestMatcher;
4
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Path\PathMatcherInterface;
7 use Symfony\Component\HttpFoundation\Request;
8 use Symfony\Component\HttpFoundation\RequestMatcherInterface;
9
10 /**
11  * Class WebprofilerRequestMatcher
12  */
13 class WebprofilerRequestMatcher implements RequestMatcherInterface {
14
15   /**
16    * @var \Drupal\Core\Config\ConfigFactoryInterface
17    */
18   private $configFactory;
19
20   /**
21    * @var \Drupal\Core\Path\PathMatcherInterface
22    */
23   private $pathMatcher;
24
25   /**
26    * @param ConfigFactoryInterface $configFactory
27    * @param \Drupal\Core\Path\PathMatcherInterface $pathMatcher
28    */
29   public function __construct(ConfigFactoryInterface $configFactory, PathMatcherInterface $pathMatcher) {
30     $this->configFactory = $configFactory;
31     $this->pathMatcher = $pathMatcher;
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function matches(Request $request) {
38     $path = $request->getPathInfo();
39
40     $patterns = $this->configFactory->get('webprofiler.config')->get('exclude');
41
42     // never add Webprofiler to phpinfo page.
43     $patterns .= "\r\n/admin/reports/status/php";
44
45     // never add Webprofiler to uninstall confirm page.
46     $patterns .= "\r\n/admin/modules/uninstall/*";
47
48     return !$this->pathMatcher->matchPath($path, $patterns);
49   }
50 }