From 8f1f3ec69908e24576deed755df578c2d914354b Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 17 Sep 2017 14:06:07 +0200 Subject: [PATCH] ZfQueryBasedTable: allow for ZfAdapter instances --- .../ipl/Web/Table/ZfQueryBasedTable.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/library/vendor/ipl/Web/Table/ZfQueryBasedTable.php b/library/vendor/ipl/Web/Table/ZfQueryBasedTable.php index 5a1d5acc..904d0610 100644 --- a/library/vendor/ipl/Web/Table/ZfQueryBasedTable.php +++ b/library/vendor/ipl/Web/Table/ZfQueryBasedTable.php @@ -4,6 +4,7 @@ namespace ipl\Web\Table; use Icinga\Data\Db\DbConnection; use Icinga\Data\Filter\Filter; +use Icinga\Exception\ProgrammingError; use ipl\Db\Zf1\FilterRenderer; use ipl\Db\Zf1\SelectPaginationAdapter; use ipl\Html\Container; @@ -12,21 +13,31 @@ use ipl\Html\Html; use ipl\Html\Link; use ipl\Web\Widget\ControlsAndContent; use ipl\Web\Url; +use Zend_Db_Adapter_Abstract as DbAdapter; abstract class ZfQueryBasedTable extends QueryBasedTable { /** @var DbConnection */ private $connection; - /** @var \Zend_Db_Adapter_Abstract */ + /** @var DbAdapter */ private $db; private $query; - public function __construct(DbConnection $connection) + public function __construct($db) { - $this->connection = $connection; - $this->db = $connection->getDbAdapter(); + if ($db instanceof DbAdapter) { + $this->db = $db; + } elseif ($db instanceof DbConnection) { + $this->connection = $db; + $this->db = $db->getDbAdapter(); + } else { + throw new ProgrammingError( + 'Unable to deal with %s db class', + get_class($db) + ); + } } public static function show(ControlsAndContent $controller, DbConnection $db)