Packages

  • dibi
    • drivers
    • nette
    • reflection
  • None
  • PHP

Classes

  • DibiNetteExtension
  • DibiNettePanel
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the "dibi" - smart database abstraction layer.
 5:  *
 6:  * Copyright (c) 2005 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  */
11: 
12: 
13: 
14: /**
15:  * Dibi extension for Nette Framework. Creates 'connection' service.
16:  *
17:  * @author     David Grudl
18:  * @package    dibi\nette
19:  * @phpversion 5.3
20:  */
21: class DibiNetteExtension extends Nette\Config\CompilerExtension
22: {
23: 
24:     public function loadConfiguration()
25:     {
26:         $container = $this->getContainerBuilder();
27:         $config = $this->getConfig();
28: 
29:         $useProfiler = isset($config['profiler'])
30:             ? $config['profiler']
31:             : !$container->parameters['productionMode'];
32: 
33:         unset($config['profiler']);
34: 
35:         if (isset($config['flags'])) {
36:             $flags = 0;
37:             foreach ((array) $config['flags'] as $flag) {
38:                 $flags |= constant($flag);
39:             }
40:             $config['flags'] = $flags;
41:         }
42: 
43:         $connection = $container->addDefinition($this->prefix('connection'))
44:             ->setClass('DibiConnection', array($config));
45: 
46:         if ($useProfiler) {
47:             $panel = $container->addDefinition($this->prefix('panel'))
48:                 ->setClass('DibiNettePanel')
49:                 ->addSetup('Nette\Diagnostics\Debugger::$bar->addPanel(?)', array('@self'))
50:                 ->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array(array('@self', 'renderException')));
51: 
52:             $connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent')));
53:         }
54:     }
55: 
56: }
57: 
dibi API documentation API documentation generated by ApiGen 2.3.0