Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into cach…
Browse files Browse the repository at this point in the history
…e_plugin_priority

Conflicts:
	library/Zend/Cache/Storage/Adapter/AbstractAdapter.php
	library/Zend/Cache/Storage/Plugin/ClearByFactor.php
	library/Zend/Cache/Storage/Plugin/ExceptionHandler.php
	library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php
	library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php
	library/Zend/Cache/Storage/Plugin/Serializer.php
  • Loading branch information
Show file tree
Hide file tree
Showing 35 changed files with 240 additions and 281 deletions.
1 change: 0 additions & 1 deletion src/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
/**
* Interface for pagination adapters.
*
* @uses Countable
* @category Zend
* @package Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/

namespace Zend\Paginator\Adapter;
use Zend\Paginator\Adapter;

use Zend\Paginator\Adapter;

/**
* @uses \Zend\Paginator\Adapter
* @category Zend
* @package Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down
82 changes: 38 additions & 44 deletions src/Adapter/DbSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@

namespace Zend\Paginator\Adapter;

use Zend\Db\Select,
Zend\Db,
Zend\Paginator\Adapter,
Zend\Paginator\Adapter\Exception;
use Zend\Db\Sql;
use Zend\Paginator;

/**
* @uses \Zend\Db\Db
* @uses \Zend\Db\Expr
* @uses \Zend\Db\Select
* @uses \Zend\Paginator\Adapter
* @uses Zend\Paginator\Adapter\Exception
* @category Zend
* @package Zend_Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class DbSelect implements Adapter
class DbSelect implements Paginator\Adapter
{
/**
* Name of the row count column
Expand All @@ -48,14 +41,14 @@ class DbSelect implements Adapter
/**
* The COUNT query
*
* @var \Zend\Db\Select
* @var \Zend\Db\Sql\Select
*/
protected $_countSelect = null;

/**
* Database query
*
* @var \Zend\Db\Select
* @var \Zend\Db\Sql\Select
*/
protected $_select = null;

Expand All @@ -69,9 +62,9 @@ class DbSelect implements Adapter
/**
* Constructor.
*
* @param \Zend\Db\Select $select The select query
* @param \Zend\Db\Sql\Select $select The select query
*/
public function __construct(Select $select)
public function __construct(Sql\Select $select)
{
$this->_select = $select;
}
Expand All @@ -86,19 +79,19 @@ public function __construct(Select $select)
* Users are therefore encouraged to profile their queries to find
* the solution that best meets their needs.
*
* @param \Zend\Db\Select|integer $totalRowCount Total row count integer
* @param \Zend\Db\Sql\Select|integer $rowCount Total row count integer
* or query
* @return \Zend\Paginator\Adapter\DbSelect $this
* @throws \Zend\Paginator\Adapter\Exception
* @throws Exception\InvalidArgumentException
* @return DbSelect
*/
public function setRowCount($rowCount)
{
if ($rowCount instanceof Select) {
$columns = $rowCount->getPart(Select::COLUMNS);
if ($rowCount instanceof Sql\Select) {
$columns = $rowCount->getPart(Sql\Select::COLUMNS);

$countColumnPart = $columns[0][1];

if ($countColumnPart instanceof Db\Expr) {
if ($countColumnPart instanceof Sql\ExpressionInterface) {
$countColumnPart = $countColumnPart->__toString();
}

Expand All @@ -124,7 +117,7 @@ public function setRowCount($rowCount)
/**
* Returns an array of items for a page.
*
* @param integer $offset Page offset
* @param integer $offset Page offset
* @param integer $itemCountPerPage Number of items per page
* @return array
*/
Expand Down Expand Up @@ -158,7 +151,7 @@ public function count()
* In that use-case I'm expecting problems when either GROUP BY or DISTINCT
* has one column.
*
* @return \Zend\Db\Select
* @return \Zend\Db\Sql\Select
*/
public function getCountSelect()
{
Expand All @@ -178,23 +171,23 @@ public function getCountSelect()
$countColumn = $db->quoteIdentifier($db->foldCase(self::ROW_COUNT_COLUMN));
$countPart = 'COUNT(1) AS ';
$groupPart = null;
$unionParts = $rowCount->getPart(Select::UNION);
$unionParts = $rowCount->getPart(Sql\Select::UNION);

/**
* If we're dealing with a UNION query, execute the UNION as a subquery
* to the COUNT query.
*/
if (!empty($unionParts)) {
$expression = new Db\Expr($countPart . $countColumn);
$rowCount = $db
->select()
->bind($rowCount->getBind())
->from($rowCount, $expression);
$expression = new Sql\Expression($countPart . $countColumn);
$rowCount = $db
->select()
->bind($rowCount->getBind())
->from($rowCount, $expression);
} else {
$columnParts = $rowCount->getPart(Select::COLUMNS);
$groupParts = $rowCount->getPart(Select::GROUP);
$havingParts = $rowCount->getPart(Select::HAVING);
$isDistinct = $rowCount->getPart(Select::DISTINCT);
$columnParts = $rowCount->getPart(Sql\Select::COLUMNS);
$groupParts = $rowCount->getPart(Sql\Select::GROUP);
$havingParts = $rowCount->getPart(Sql\Select::HAVING);
$isDistinct = $rowCount->getPart(Sql\Select::DISTINCT);

/**
* If there is more than one column AND it's a DISTINCT query, more
Expand All @@ -206,7 +199,7 @@ public function getCountSelect()
} else if ($isDistinct) {
$part = $columnParts[0];

if ($part[1] !== Select::SQL_WILDCARD && !($part[1] instanceof Db\Expr)) {
if ($part[1] !== Sql\Select::SQL_WILDCARD && !($part[1] instanceof Sql\ExpressionInterface)) {
$column = $db->quoteIdentifier($part[1], true);

if (!empty($part[0])) {
Expand All @@ -215,8 +208,9 @@ public function getCountSelect()

$groupPart = $column;
}
} else if (!empty($groupParts) && $groupParts[0] !== Select::SQL_WILDCARD &&
!($groupParts[0] instanceof Db\Expr)) {
} else if (!empty($groupParts) && $groupParts[0] !== Sql\Select::SQL_WILDCARD &&
!($groupParts[0] instanceof Sql\ExpressionInterface)
) {
$groupPart = $db->quoteIdentifier($groupParts[0], true);
}

Expand All @@ -232,15 +226,15 @@ public function getCountSelect()
/**
* Create the COUNT part of the query
*/
$expression = new Db\Expr($countPart . $countColumn);

$rowCount->reset(Select::COLUMNS)
->reset(Select::ORDER)
->reset(Select::LIMIT_OFFSET)
->reset(Select::GROUP)
->reset(Select::DISTINCT)
->reset(Select::HAVING)
->columns($expression);
$expression = new Sql\Expression($countPart . $countColumn);

$rowCount->reset(Sql\Select::COLUMNS)
->reset(Sql\Select::ORDER)
->reset(Sql\Select::LIMIT_OFFSET)
->reset(Sql\Select::GROUP)
->reset(Sql\Select::DISTINCT)
->reset(Sql\Select::HAVING)
->columns($expression);
}

$this->_countSelect = $rowCount;
Expand Down
3 changes: 1 addition & 2 deletions src/Adapter/DbTableSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
namespace Zend\Paginator\Adapter;

/**
* @uses \Zend\Paginator\Adapter\DbSelect
* @category Zend
* @package Zend_Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand All @@ -30,7 +29,7 @@
class DbTableSelect extends DbSelect
{
/**
* Returns a Zend_Db_Table_Rowset_Abstract of items for a page.
* Returns a Zend\Db\Table\AbstractRowset of items for a page.
*
* @param integer $offset Page offset
* @param integer $itemCountPerPage Number of items per page
Expand Down
1 change: 0 additions & 1 deletion src/Adapter/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Zend\Paginator\Adapter;

/**
* @uses Zend\Paginator\Exception
* @category Zend
* @package Zend_Paginator
* @subpackage Adapter
Expand Down
1 change: 0 additions & 1 deletion src/Adapter/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Zend\Paginator\Adapter\Exception;

/**
* @uses Zend\Paginator\Adapter\Exception
* @category Zend
* @package Zend\Paginator\Adapter
* @subpackage Exception
Expand Down
1 change: 0 additions & 1 deletion src/Adapter/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Zend\Paginator\Adapter\Exception;

/**
* @uses Zend\Paginator\Adapter\Exception
* @category Zend
* @package Zend\Paginator\Adapter
* @subpackage Exception
Expand Down
1 change: 0 additions & 1 deletion src/Adapter/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Zend\Paginator\Adapter\Exception;

/**
* @uses Zend\Paginator\Adapter\Exception
* @category Zend
* @package Zend\Paginator\Adapter
* @subpackage Exception
Expand Down
15 changes: 6 additions & 9 deletions src/Adapter/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@

namespace Zend\Paginator\Adapter;

use Zend\Paginator\Adapter;
use Zend\Paginator;

/**
* @uses \Zend\Paginator\Adapter
* @uses \Zend\Paginator\Adapter\Exception
* @uses \Zend\Paginator\SerializableLimitIterator
* @category Zend
* @package Zend_Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Iterator implements Adapter
class Iterator implements Paginator\Adapter
{
/**
* Iterator which implements Countable
Expand All @@ -50,8 +47,8 @@ class Iterator implements Adapter
/**
* Constructor.
*
* @param Iterator $iterator Iterator to paginate
* @throws \Zend\Paginator\Adapter\Exception
* @param \Iterator $iterator Iterator to paginate
* @throws \Zend\Paginator\Adapter\Exception\InvalidArgumentException
*/
public function __construct(\Iterator $iterator)
{
Expand All @@ -68,14 +65,14 @@ public function __construct(\Iterator $iterator)
*
* @param integer $offset Page offset
* @param integer $itemCountPerPage Number of items per page
* @return LimitIterator|array
* @return array|\Zend\Paginator\SerializableLimitIterator
*/
public function getItems($offset, $itemCountPerPage)
{
if ($this->_count == 0) {
return array();
}
return new \Zend\Paginator\SerializableLimitIterator($this->_iterator, $offset, $itemCountPerPage);
return new Paginator\SerializableLimitIterator($this->_iterator, $offset, $itemCountPerPage);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Adapter/Null.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Zend\Paginator\Adapter;

/**
* @uses \Zend\Paginator\Adapter
* @category Zend
* @package Zend_Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand All @@ -41,7 +40,7 @@ class Null implements Adapter
/**
* Constructor.
*
* @param array $count Total item count
* @param integer $count Total item count (Optional)
*/
public function __construct($count = 0)
{;
Expand Down
6 changes: 3 additions & 3 deletions src/AdapterAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Zend\Paginator;

/**
* Interface that aggregates a Zend_Paginator_Adapter_Abstract just like IteratorAggregate does for Iterators.
* Interface that aggregates a Zend\Paginator\Adapter\Abstract just like IteratorAggregate does for Iterators.
*
* @category Zend
* @package Zend_Paginator
Expand All @@ -35,7 +35,7 @@ interface AdapterAggregate
/**
* Return a fully configured Paginator Adapter from this method.
*
* @return Zend_Paginator_Adapter_Interface
* @return \Zend\Paginator\Adapter
*/
public function getPaginatorAdapter();
}
}
8 changes: 4 additions & 4 deletions src/AdapterBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ class AdapterBroker extends PluginBroker
protected $defaultClassLoader = 'Zend\Paginator\AdapterLoader';

/**
* @var boolean Adapters must not be registred on load
* @var boolean Adapters must not be registered on load
*/
protected $registerPluginsOnLoad = false;

/**
* Determine if we have a valid adapter
*
* @param mixed $plugin
* @return true
* @throws Exception
* @return bool
* @throws Exception\InvalidArgumentException
*/
protected function validatePlugin($plugin)
{
if (!$plugin instanceof Adapter) {
throw new Exception('Pagination adapters must implement Zend\Paginator\Adapter');
throw new Exception\InvalidArgumentException('Pagination adapters must implement Zend\Paginator\Adapter');
}
return true;
}
Expand Down
1 change: 0 additions & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
namespace Zend\Paginator;

/**
* @uses Zend\Exception
* @category Zend
* @package Zend_Paginator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down
1 change: 0 additions & 1 deletion src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Zend\Paginator\Exception;

/**
* @uses Zend\Paginator\Exception
* @category Zend
* @package Zend\Paginator
* @subpackage Exception
Expand Down
1 change: 0 additions & 1 deletion src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Zend\Paginator\Exception;

/**
* @uses Zend\Paginator\Exception
* @category Zend
* @package Zend\Paginator
* @subpackage Exception
Expand Down

0 comments on commit 1302f0b

Please sign in to comment.