3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Feed\Writer;
12 use Zend\Feed\Writer\Exception\InvalidArgumentException;
14 class StandaloneExtensionManager implements ExtensionManagerInterface
16 private $extensions = [
17 'Atom\Renderer\Feed' => Extension\Atom\Renderer\Feed::class,
18 'Content\Renderer\Entry' => Extension\Content\Renderer\Entry::class,
19 'DublinCore\Renderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
20 'DublinCore\Renderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
21 'GooglePlayPodcast\Entry' => Extension\GooglePlayPodcast\Entry::class,
22 'GooglePlayPodcast\Feed' => Extension\GooglePlayPodcast\Feed::class,
23 'GooglePlayPodcast\Renderer\Entry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
24 'GooglePlayPodcast\Renderer\Feed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
25 'ITunes\Entry' => Extension\ITunes\Entry::class,
26 'ITunes\Feed' => Extension\ITunes\Feed::class,
27 'ITunes\Renderer\Entry' => Extension\ITunes\Renderer\Entry::class,
28 'ITunes\Renderer\Feed' => Extension\ITunes\Renderer\Feed::class,
29 'Slash\Renderer\Entry' => Extension\Slash\Renderer\Entry::class,
30 'Threading\Renderer\Entry' => Extension\Threading\Renderer\Entry::class,
31 'WellFormedWeb\Renderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
35 * Do we have the extension?
37 * @param string $extension
40 public function has($extension)
42 return array_key_exists($extension, $this->extensions);
46 * Retrieve the extension
48 * @param string $extension
51 public function get($extension)
53 $class = $this->extensions[$extension];
61 * @param string $class
63 public function add($name, $class)
67 is_a($class, Extension\AbstractRenderer::class, true)
68 || 'Feed' === substr($class, -4)
69 || 'Entry' === substr($class, -5)
72 $this->extensions[$name] = $class;
77 throw new InvalidArgumentException(sprintf(
78 'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
79 . 'or the classname must end in "Feed" or "Entry"',
86 * Remove an extension.
90 public function remove($name)
92 unset($this->extensions[$name]);