|
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\Bundle\WebProfilerBundle\DependencyInjection; |
|
13 |
|
14 use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
15 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
|
16 use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17 use Symfony\Component\Config\FileLocator; |
|
18 use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; |
|
19 |
|
20 /** |
|
21 * WebProfilerExtension. |
|
22 * |
|
23 * Usage: |
|
24 * |
|
25 * <webprofiler:config |
|
26 * toolbar="true" |
|
27 * intercept-redirects="true" |
|
28 * /> |
|
29 * |
|
30 * @author Fabien Potencier <fabien@symfony.com> |
|
31 */ |
|
32 class WebProfilerExtension extends Extension |
|
33 { |
|
34 /** |
|
35 * Loads the web profiler configuration. |
|
36 * |
|
37 * @param array $configs An array of configuration settings |
|
38 * @param ContainerBuilder $container A ContainerBuilder instance |
|
39 */ |
|
40 public function load(array $configs, ContainerBuilder $container) |
|
41 { |
|
42 $configuration = new Configuration(); |
|
43 $config = $this->processConfiguration($configuration, $configs); |
|
44 |
|
45 $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
46 $loader->load('toolbar.xml'); |
|
47 |
|
48 $container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']); |
|
49 |
|
50 if (!$config['toolbar']) { |
|
51 $mode = WebDebugToolbarListener::DISABLED; |
|
52 } elseif ($config['verbose']) { |
|
53 $mode = WebDebugToolbarListener::ENABLED; |
|
54 } else { |
|
55 $mode = WebDebugToolbarListener::ENABLED_MINIMAL; |
|
56 } |
|
57 $container->setParameter('web_profiler.debug_toolbar.mode', $mode); |
|
58 } |
|
59 |
|
60 /** |
|
61 * Returns the base path for the XSD files. |
|
62 * |
|
63 * @return string The XSD base path |
|
64 */ |
|
65 public function getXsdValidationBasePath() |
|
66 { |
|
67 return __DIR__.'/../Resources/config/schema'; |
|
68 } |
|
69 |
|
70 public function getNamespace() |
|
71 { |
|
72 return 'http://symfony.com/schema/dic/webprofiler'; |
|
73 } |
|
74 } |