From f7fd9104e95315727daec06a59bbd38a91769cb0 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 13 Jan 2015 06:58:53 +0100 Subject: [PATCH] removed bridge for Nette 2.0 (BC break) --- .../Nette-2.0/DibiNette20Extension.php | 55 ------------------- dibi/bridges/Nette-2.0/config.sample.neon | 17 ------ dibi/bridges/Nette-2.1/DibiNettePanel.php | 28 ++-------- dibi/dibi.php | 4 -- dibi/libs/DibiConnection.php | 2 +- 5 files changed, 6 insertions(+), 100 deletions(-) delete mode 100644 dibi/bridges/Nette-2.0/DibiNette20Extension.php delete mode 100644 dibi/bridges/Nette-2.0/config.sample.neon diff --git a/dibi/bridges/Nette-2.0/DibiNette20Extension.php b/dibi/bridges/Nette-2.0/DibiNette20Extension.php deleted file mode 100644 index ae657b3b..00000000 --- a/dibi/bridges/Nette-2.0/DibiNette20Extension.php +++ /dev/null @@ -1,55 +0,0 @@ -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::$bar->addPanel(?)', array('@self')) - ->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array('DibiNettePanel::renderException')); - - $connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent'))); - } - } - -} diff --git a/dibi/bridges/Nette-2.0/config.sample.neon b/dibi/bridges/Nette-2.0/config.sample.neon deleted file mode 100644 index e2450145..00000000 --- a/dibi/bridges/Nette-2.0/config.sample.neon +++ /dev/null @@ -1,17 +0,0 @@ -# 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-2.1/DibiNettePanel.php b/dibi/bridges/Nette-2.1/DibiNettePanel.php index 49eee3b1..f938a874 100644 --- a/dibi/bridges/Nette-2.1/DibiNettePanel.php +++ b/dibi/bridges/Nette-2.1/DibiNettePanel.php @@ -5,10 +5,7 @@ * Copyright (c) 2005 David Grudl (http://davidgrudl.com) */ - -if (interface_exists('Nette\Diagnostics\IBarPanel')) { - class_alias('Nette\Diagnostics\IBarPanel', 'IBarPanel'); -} +use Nette\Diagnostics\Debugger; /** @@ -17,7 +14,7 @@ if (interface_exists('Nette\Diagnostics\IBarPanel')) { * @author David Grudl * @package dibi\nette */ -class DibiNettePanel extends DibiObject implements IBarPanel +class DibiNettePanel extends DibiObject implements Nette\Diagnostics\IBarPanel { /** @var int maximum SQL length */ static public $maxLength = 1000; @@ -41,24 +38,9 @@ class DibiNettePanel extends DibiObject implements IBarPanel public function register(DibiConnection $connection) { - if (is_callable('Nette\Diagnostics\Debugger::enable') && !class_exists('NDebugger')) { - class_alias('Nette\Diagnostics\Debugger', 'NDebugger'); // PHP 5.2 code compatibility - } - if (is_callable('NDebugger::enable') && is_callable('NDebugger::getBlueScreen')) { // Nette Framework 2.1 - NDebugger::getBar()->addPanel($this); - NDebugger::getBlueScreen()->addPanel(array(__CLASS__, 'renderException')); - $connection->onEvent[] = array($this, 'logEvent'); - - } elseif (is_callable('NDebugger::enable')) { // Nette Framework 2.0 (for PHP 5.3 or PHP 5.2 prefixed) - NDebugger::$bar && NDebugger::$bar->addPanel($this); - NDebugger::$blueScreen && NDebugger::$blueScreen->addPanel(array(__CLASS__, 'renderException'), __CLASS__); - $connection->onEvent[] = array($this, 'logEvent'); - - } elseif (is_callable('Debugger::enable') && !is_callable('Debugger::getBlueScreen')) { // Nette Framework 2.0 for PHP 5.2 non-prefixed - Debugger::$bar && Debugger::$bar->addPanel($this); - Debugger::$blueScreen && Debugger::$blueScreen->addPanel(array(__CLASS__, 'renderException'), __CLASS__); - $connection->onEvent[] = array($this, 'logEvent'); - } + Debugger::getBar()->addPanel($this); + Debugger::getBlueScreen()->addPanel(array(__CLASS__, 'renderException')); + $connection->onEvent[] = array($this, 'logEvent'); } diff --git a/dibi/dibi.php b/dibi/dibi.php index 57380711..c8dd7b2e 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -33,7 +33,3 @@ require_once dirname(__FILE__) . '/libs/DibiDatabaseInfo.php'; require_once dirname(__FILE__) . '/libs/DibiEvent.php'; require_once dirname(__FILE__) . '/libs/DibiFileLogger.php'; require_once dirname(__FILE__) . '/libs/DibiFirePhpLogger.php'; - -if (interface_exists('Nette\Diagnostics\IBarPanel') || interface_exists('IBarPanel')) { - require_once dirname(__FILE__) . '/bridges/Nette-2.1/DibiNettePanel.php'; -} diff --git a/dibi/libs/DibiConnection.php b/dibi/libs/DibiConnection.php index 7faf6552..256740b1 100644 --- a/dibi/libs/DibiConnection.php +++ b/dibi/libs/DibiConnection.php @@ -111,7 +111,7 @@ class DibiConnection extends DibiObject $this->onEvent[] = array(new DibiFirePhpLogger($filter), 'logEvent'); } - if (!interface_exists('Tracy\IBarPanel') && (interface_exists('Nette\Diagnostics\IBarPanel') || interface_exists('IBarPanel'))) { + if (!interface_exists('Tracy\IBarPanel') && interface_exists('Nette\Diagnostics\IBarPanel') && class_exists('DibiNettePanel')) { $panel = new DibiNettePanel(isset($profilerCfg['explain']) ? $profilerCfg['explain'] : TRUE, $filter); $panel->register($this); }