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\I18n\Translator
;
12 use Zend\I18n\Exception
;
13 use Zend\ServiceManager\AbstractPluginManager
;
16 * Plugin manager implementation for translation loaders.
18 * Enforces that loaders retrieved are either instances of
19 * Loader\FileLoaderInterface or Loader\RemoteLoaderInterface. Additionally,
20 * it registers a number of default loaders.
22 class LoaderPluginManager
extends AbstractPluginManager
25 * Default set of loaders.
29 protected $invokableClasses = array(
30 'gettext' => 'Zend\I18n\Translator\Loader\Gettext',
31 'ini' => 'Zend\I18n\Translator\Loader\Ini',
32 'phparray' => 'Zend\I18n\Translator\Loader\PhpArray',
36 * Validate the plugin.
38 * Checks that the filter loaded is an instance of
39 * Loader\FileLoaderInterface or Loader\RemoteLoaderInterface.
41 * @param mixed $plugin
43 * @throws Exception\RuntimeException if invalid
45 public function validatePlugin($plugin)
47 if ($plugin instanceof Loader\FileLoaderInterface ||
$plugin instanceof Loader\RemoteLoaderInterface
) {
52 throw new Exception\
RuntimeException(sprintf(
53 'Plugin of type %s is invalid; must implement %s\Loader\FileLoaderInterface or %s\Loader\RemoteLoaderInterface',
54 (is_object($plugin) ?
get_class($plugin) : gettype($plugin)),