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\Reader;
12 use Zend\Feed\Reader\Exception\InvalidArgumentException;
14 class StandaloneExtensionManager implements ExtensionManagerInterface
16 private $extensions = [
17 'Atom\Entry' => Extension\Atom\Entry::class,
18 'Atom\Feed' => Extension\Atom\Feed::class,
19 'Content\Entry' => Extension\Content\Entry::class,
20 'CreativeCommons\Entry' => Extension\CreativeCommons\Entry::class,
21 'CreativeCommons\Feed' => Extension\CreativeCommons\Feed::class,
22 'DublinCore\Entry' => Extension\DublinCore\Entry::class,
23 'DublinCore\Feed' => Extension\DublinCore\Feed::class,
24 'Podcast\Entry' => Extension\Podcast\Entry::class,
25 'Podcast\Feed' => Extension\Podcast\Feed::class,
26 'Slash\Entry' => Extension\Slash\Entry::class,
27 'Syndication\Feed' => Extension\Syndication\Feed::class,
28 'Thread\Entry' => Extension\Thread\Entry::class,
29 'WellFormedWeb\Entry' => Extension\WellFormedWeb\Entry::class,
33 * Do we have the extension?
35 * @param string $extension
38 public function has($extension)
40 return array_key_exists($extension, $this->extensions);
44 * Retrieve the extension
46 * @param string $extension
47 * @return Extension\AbstractEntry|Extension\AbstractFeed
49 public function get($extension)
51 $class = $this->extensions[$extension];
59 * @param string $class
61 public function add($name, $class)
65 is_a($class, Extension\AbstractEntry::class, true)
66 || is_a($class, Extension\AbstractFeed::class, true)
69 $this->extensions[$name] = $class;
73 throw new InvalidArgumentException(sprintf(
74 'Plugin of type %s is invalid; must implement %2$s\Extension\AbstractFeed '
75 . 'or %2$s\Extension\AbstractEntry',
82 * Remove an extension.
86 public function remove($name)
88 unset($this->extensions[$name]);