mirror of
https://github.com/dg/dibi.git
synced 2025-08-21 05:11:49 +02:00
# Conflicts: # dibi/bridges/Tracy/Panel.php # dibi/drivers/DibiPdoDriver.php # dibi/drivers/DibiPostgreDriver.php # tests/dibi/DataSource.phpt # tests/dibi/DibiConnection.connect.phpt # tests/dibi/DibiConnection.transactions.phpt # tests/dibi/DibiFluent.cloning.phpt # tests/dibi/DibiFluent.insert.phpt # tests/dibi/DibiFluent.select.phpt # tests/dibi/DibiFluent.update.phpt # tests/dibi/DibiTranslator.conditions.phpt # tests/dibi/DibiTranslator.phpt # tests/dibi/PdoMssql.limits.phpt # tests/dibi/Postgre.like.phpt
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This file is part of the "dibi" - smart database abstraction layer.
|
|
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
|
|
*/
|
|
|
|
namespace Dibi\Bridges\Nette;
|
|
|
|
use dibi;
|
|
use Nette;
|
|
|
|
|
|
/**
|
|
* Dibi extension for Nette Framework 2.2. Creates 'connection' & 'panel' services.
|
|
*
|
|
* @author David Grudl
|
|
* @package dibi\nette
|
|
*/
|
|
class DibiExtension22 extends Nette\DI\CompilerExtension
|
|
{
|
|
|
|
public function loadConfiguration()
|
|
{
|
|
$container = $this->getContainerBuilder();
|
|
$config = $this->getConfig();
|
|
|
|
$useProfiler = isset($config['profiler'])
|
|
? $config['profiler']
|
|
: class_exists('Tracy\Debugger') && $container->parameters['debugMode'];
|
|
|
|
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('Dibi\Bridges\Tracy\Panel');
|
|
$connection->addSetup(array($panel, 'register'), array($connection));
|
|
}
|
|
}
|
|
|
|
}
|