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

Commit

Permalink
Show file tree
Hide file tree
Showing 29 changed files with 448 additions and 118 deletions.
4 changes: 0 additions & 4 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter;
Expand All @@ -14,9 +13,6 @@

/**
* Interface for pagination adapters.
*
* @category Zend
* @package Paginator
*/
interface AdapterInterface extends Countable
{
Expand Down
5 changes: 0 additions & 5 deletions src/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter;

/**
* @category Zend
* @package Paginator
*/
class ArrayAdapter implements AdapterInterface
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Adapter/DbSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter;
Expand All @@ -17,10 +16,6 @@
use Zend\Db\ResultSet\ResultSetInterface;
use Zend\Db\ResultSet\ResultSet;

/**
* @category Zend
* @package Zend_Paginator
*/
class DbSelect implements AdapterInterface
{

Expand Down
6 changes: 0 additions & 6 deletions src/Adapter/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter\Exception;

use Zend\Paginator\Exception\ExceptionInterface as Exception;

/**
* @category Zend
* @package Zend_Paginator
* @subpackage Adapter
*/
interface ExceptionInterface extends Exception
{}
6 changes: 0 additions & 6 deletions src/Adapter/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter\Exception;

use Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend\Paginator\Adapter
* @subpackage Exception
*/
class InvalidArgumentException extends Exception\InvalidArgumentException implements
ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Adapter/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter\Exception;

use Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend\Paginator\Adapter
* @subpackage Exception
*/
class RuntimeException extends Exception\RuntimeException implements
ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Adapter/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter\Exception;

use Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend\Paginator\Adapter
* @subpackage Exception
*/
class UnexpectedValueException extends Exception\UnexpectedValueException implements
ExceptionInterface
{}
5 changes: 0 additions & 5 deletions src/Adapter/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter;

use Zend\Paginator;

/**
* @category Zend
* @package Zend_Paginator
*/
class Iterator implements AdapterInterface
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Adapter/Null.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Adapter;

/**
* @category Zend
* @package Zend_Paginator
*/
class Null implements AdapterInterface
{
/**
Expand Down
41 changes: 41 additions & 0 deletions src/Adapter/Service/DbSelectFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Paginator\Adapter\Service;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class DbSelectFactory implements FactoryInterface
{
/**
* Adapter options
* @var array
*/
protected $creationOptions;

/**
* Construct with adapter options
* @param array $creationOptions
*/
public function __construct(array $creationOptions)
{
$this->creationOptions = $creationOptions;
}

/**
* @param ServiceLocatorInterface $serviceLocator
* @return \Zend\Navigation\Navigation
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$class = new \ReflectionClass('Zend\Paginator\Adapter\DbSelect');
return $class->newInstanceArgs($this->creationOptions);
}
}
5 changes: 0 additions & 5 deletions src/AdapterAggregateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator;
Expand All @@ -14,10 +13,6 @@

/**
* Interface that aggregates a Zend\Paginator\Adapter\Abstract just like IteratorAggregate does for Iterators.
*
* @category Zend
* @package Zend_Paginator
* @subpackage Adapter
*/
interface AdapterAggregateInterface
{
Expand Down
84 changes: 84 additions & 0 deletions src/AdapterPluginManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Paginator;

use Zend\ServiceManager\AbstractPluginManager;

/**
* Plugin manager implementation for paginator adapters.
*
* Enforces that adapters retrieved are instances of
* Adapter\AdapterInterface. Additionally, it registers a number of default
* adapters available.
*/
class AdapterPluginManager extends AbstractPluginManager
{
/**
* Default set of adapters
*
* @var array
*/
protected $invokableClasses = array(
'array' => 'Zend\Paginator\Adapter\ArrayAdapter',
'iterator' => 'Zend\Paginator\Adapter\Iterator',
'null' => 'Zend\Paginator\Adapter\Null',
);

/**
* Default set of adapter factories
*
* @var array
*/
protected $factories = array(
'dbselect' => 'Zend\Paginator\Adapter\Service\DbSelectFactory'
);

/**
* Attempt to create an instance via a factory
*
* @param string $canonicalName
* @param string $requestedName
* @return mixed
* @throws Exception\ServiceNotCreatedException If factory is not callable
*/
protected function createFromFactory($canonicalName, $requestedName)
{
$factory = $this->factories[$canonicalName];
if (is_string($factory) && class_exists($factory, true)) {
$factory = new $factory($this->creationOptions);
$this->factories[$canonicalName] = $factory;
}
return parent::createFromFactory($canonicalName, $requestedName);
}

/**
* Validate the plugin
*
* Checks that the adapter loaded is an instance
* of Adapter\AdapterInterface.
*
* @param mixed $plugin
* @return void
* @throws Exception\RuntimeException if invalid
*/
public function validatePlugin($plugin)
{
if ($plugin instanceof Adapter\AdapterInterface) {
// we're okay
return;
}

throw new Exception\RuntimeException(sprintf(
'Plugin of type %s is invalid; must implement %s\Adapter\AdapterInterface',
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
__NAMESPACE__
));
}
}
5 changes: 0 additions & 5 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend_Paginator
*/
interface ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend\Paginator
* @subpackage Exception
*/
class InvalidArgumentException
extends \InvalidArgumentException
implements ExceptionInterface
Expand Down
6 changes: 0 additions & 6 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend\Paginator
* @subpackage Exception
*/
class RuntimeException
extends \RuntimeException
implements ExceptionInterface
Expand Down
6 changes: 0 additions & 6 deletions src/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Paginator
*/

namespace Zend\Paginator\Exception;

/**
* @category Zend
* @package Zend\Paginator
* @subpackage Exception
*/
class UnexpectedValueException
extends \UnexpectedValueException
implements ExceptionInterface
Expand Down

0 comments on commit af38e3f

Please sign in to comment.