WriterPluginManager.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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-2014 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 WriterPluginManager extends AbstractPluginManager
  12. {
  13. protected $invokableClasses = array(
  14. 'ini' => 'Zend\Config\Writer\Ini',
  15. 'json' => 'Zend\Config\Writer\Json',
  16. 'php' => 'Zend\Config\Writer\PhpArray',
  17. 'yaml' => 'Zend\Config\Writer\Yaml',
  18. 'xml' => 'Zend\Config\Writer\Xml',
  19. );
  20. public function validatePlugin($plugin)
  21. {
  22. if ($plugin instanceof Writer\AbstractWriter) {
  23. return;
  24. }
  25. $type = is_object($plugin) ? get_class($plugin) : gettype($plugin);
  26. throw new Exception\InvalidArgumentException(
  27. "Plugin of type {$type} is invalid. Plugin must extend ". __NAMESPACE__ . '\Writer\AbstractWriter'
  28. );
  29. }
  30. }