3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Paginator
;
12 use Zend\ServiceManager\AbstractPluginManager
;
15 * Plugin manager implementation for paginator adapters.
17 * Enforces that adapters retrieved are instances of
18 * Adapter\AdapterInterface. Additionally, it registers a number of default
21 class AdapterPluginManager
extends AbstractPluginManager
24 * Default set of adapters
28 protected $invokableClasses = array(
29 'array' => 'Zend\Paginator\Adapter\ArrayAdapter',
30 'iterator' => 'Zend\Paginator\Adapter\Iterator',
31 'null' => 'Zend\Paginator\Adapter\Null',
35 * Default set of adapter factories
39 protected $factories = array(
40 'dbselect' => 'Zend\Paginator\Adapter\Service\DbSelectFactory'
44 * Attempt to create an instance via a factory
46 * @param string $canonicalName
47 * @param string $requestedName
49 * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException If factory is not callable
51 protected function createFromFactory($canonicalName, $requestedName)
53 $factory = $this->factories
[$canonicalName];
54 if (is_string($factory) && class_exists($factory, true)) {
55 $factory = new $factory($this->creationOptions
);
56 $this->factories
[$canonicalName] = $factory;
58 return parent
::createFromFactory($canonicalName, $requestedName);
64 * Checks that the adapter loaded is an instance
65 * of Adapter\AdapterInterface.
67 * @param mixed $plugin
69 * @throws Exception\RuntimeException if invalid
71 public function validatePlugin($plugin)
73 if ($plugin instanceof Adapter\AdapterInterface
) {
78 throw new Exception\
RuntimeException(sprintf(
79 'Plugin of type %s is invalid; must implement %s\Adapter\AdapterInterface',
80 (is_object($plugin) ?
get_class($plugin) : gettype($plugin)),