ReaderPluginManager.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  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
  8. */
  9. namespace Zend\Config;
  10. use Zend\ServiceManager\AbstractPluginManager;
  11. class ReaderPluginManager extends AbstractPluginManager
  12. {
  13. /**
  14. * Default set of readers
  15. *
  16. * @var array
  17. */
  18. protected $invokableClasses = array(
  19. 'ini' => 'Zend\Config\Reader\Ini',
  20. 'json' => 'Zend\Config\Reader\Json',
  21. 'xml' => 'Zend\Config\Reader\Xml',
  22. 'yaml' => 'Zend\Config\Reader\Yaml',
  23. );
  24. /**
  25. * Validate the plugin
  26. * Checks that the reader loaded is an instance of Reader\ReaderInterface.
  27. *
  28. * @param Reader\ReaderInterface $plugin
  29. * @return void
  30. * @throws Exception\InvalidArgumentException if invalid
  31. */
  32. public function validatePlugin($plugin)
  33. {
  34. if ($plugin instanceof Reader\ReaderInterface) {
  35. // we're okay
  36. return;
  37. }
  38. throw new Exception\InvalidArgumentException(sprintf(
  39. 'Plugin of type %s is invalid; must implement %s\Reader\ReaderInterface',
  40. (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
  41. __NAMESPACE__
  42. ));
  43. }
  44. }