1 <?php
2 3 4 5 6 7 8 9 10
11
12 namespace Neevo\Nette;
13
14 use Nette\Config\CompilerExtension;
15
16
17 18 19 20
21 class Extension extends CompilerExtension {
22
23
24 public function loadConfiguration(){
25 $container = $this->getContainerBuilder();
26 $config = $this->getConfig();
27
28 $panelEvents = $container->parameters['productionMode']
29 ? DebugPanel::EXCEPTION
30 : DebugPanel::QUERY + DebugPanel::EXCEPTION;
31
32
33 $cache = $container->addDefinition($this->prefix($c = 'cache'))
34 ->setClass('Neevo\Nette\CacheAdapter', array(ucfirst($this->prefix($c))));
35
36
37 $manager = $container->addDefinition($this->prefix('manager'))
38 ->setClass('Neevo\Manager', array($config, $this->prefix('@cache')));
39
40
41 $panelName = 'Neevo-Nette-DebugPanel-' . ucfirst($this->name);
42 $panel = $container->addDefinition($this->prefix('panel'))
43 ->setClass('Neevo\Nette\DebugPanel', array(ucfirst($this->name)))
44 ->addSetup('$service->setExplain(?)', !$container->parameters['productionMode'])
45 ->addSetup('Nette\Diagnostics\Debugger::$bar->addPanel(?, ?)', array('@self', $panelName))
46 ->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array(array('@self', 'renderException')));
47
48 $manager->addSetup('$service->attachObserver(?, ?)', array($panel, $panelEvents));
49 }
50
51
52 }
53