diff --git a/dibi/bridges/Nette/DibiNette21Extension.php b/dibi/bridges/Nette/DibiNette21Extension.php new file mode 100644 index 00000000..551b6123 --- /dev/null +++ b/dibi/bridges/Nette/DibiNette21Extension.php @@ -0,0 +1,56 @@ +getContainerBuilder(); + $config = $this->getConfig(); + + $useProfiler = isset($config['profiler']) + ? $config['profiler'] + : !$container->parameters['productionMode']; + + unset($config['profiler']); + + if (isset($config['flags'])) { + $flags = 0; + foreach ((array) $config['flags'] as $flag) { + $flags |= constant($flag); + } + $config['flags'] = $flags; + } + + $connection = $container->addDefinition($this->prefix('connection')) + ->setClass('DibiConnection', array($config)); + + if ($useProfiler) { + $panel = $container->addDefinition($this->prefix('panel')) + ->setClass('DibiNettePanel') + ->addSetup('Nette\Diagnostics\Debugger::getBar()->addPanel(?)', array('@self')) + ->addSetup('Nette\Diagnostics\Debugger::getBlueScreen()->addPanel(?)', array(array('@self', 'renderException'))); + + $connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent'))); + } + } + +} diff --git a/dibi/bridges/Nette/examples/config.nette-2.0.neon b/dibi/bridges/Nette/examples/config.nette-2.0.neon new file mode 100644 index 00000000..e2450145 --- /dev/null +++ b/dibi/bridges/Nette/examples/config.nette-2.0.neon @@ -0,0 +1,17 @@ +# Requires Nette Framework 2.0 for PHP 5.3 +# +# In bootstrap.php append these lines after line $configurator = new Nette\Config\Configurator; +# +# $configurator->onCompile[] = function($configurator, $compiler) { +# $compiler->addExtension('dibi', new DibiNette20Extension); +# }; +# +# This will create service named 'dibi.connection'. + +common: + dibi: + host: localhost + username: root + password: *** + database: foo + lazy: TRUE diff --git a/dibi/bridges/Nette/examples/config.nette-2.1.neon b/dibi/bridges/Nette/examples/config.nette-2.1.neon new file mode 100644 index 00000000..721cf421 --- /dev/null +++ b/dibi/bridges/Nette/examples/config.nette-2.1.neon @@ -0,0 +1,12 @@ +# This will create service named 'dibi.connection'. +# Requires Nette Framework 2.1 + +extensions: + dibi: DibiNette21Extension + +dibi: + host: localhost + username: root + password: *** + database: foo + lazy: TRUE