Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / zendframework / zend-feed / src / Writer / StandaloneExtensionManager.php
index c9a88c76aba3cdf3059489e7e6790a14df27f371..1e6ae7d1b72a830014735f2934ab3776e4e06fd2 100644 (file)
@@ -9,6 +9,8 @@
 
 namespace Zend\Feed\Writer;
 
+use Zend\Feed\Writer\Exception\InvalidArgumentException;
+
 class StandaloneExtensionManager implements ExtensionManagerInterface
 {
     private $extensions = [
@@ -16,6 +18,10 @@ class StandaloneExtensionManager implements ExtensionManagerInterface
         'Content\Renderer\Entry'       => Extension\Content\Renderer\Entry::class,
         'DublinCore\Renderer\Entry'    => Extension\DublinCore\Renderer\Entry::class,
         'DublinCore\Renderer\Feed'     => Extension\DublinCore\Renderer\Feed::class,
+        'GooglePlayPodcast\Entry'          => Extension\GooglePlayPodcast\Entry::class,
+        'GooglePlayPodcast\Feed'           => Extension\GooglePlayPodcast\Feed::class,
+        'GooglePlayPodcast\Renderer\Entry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
+        'GooglePlayPodcast\Renderer\Feed'  => Extension\GooglePlayPodcast\Renderer\Feed::class,
         'ITunes\Entry'                 => Extension\ITunes\Entry::class,
         'ITunes\Feed'                  => Extension\ITunes\Feed::class,
         'ITunes\Renderer\Entry'        => Extension\ITunes\Renderer\Entry::class,
@@ -47,4 +53,42 @@ class StandaloneExtensionManager implements ExtensionManagerInterface
         $class = $this->extensions[$extension];
         return new $class();
     }
+
+    /**
+     * Add an extension.
+     *
+     * @param string $name
+     * @param string $class
+     */
+    public function add($name, $class)
+    {
+        if (is_string($class)
+            && ((
+                is_a($class, Extension\AbstractRenderer::class, true)
+                || 'Feed' === substr($class, -4)
+                || 'Entry' === substr($class, -5)
+            ))
+        ) {
+            $this->extensions[$name] = $class;
+
+            return;
+        }
+
+        throw new InvalidArgumentException(sprintf(
+            'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
+            . 'or the classname must end in "Feed" or "Entry"',
+            $class,
+            __NAMESPACE__
+        ));
+    }
+
+    /**
+     * Remove an extension.
+     *
+     * @param string $name
+     */
+    public function remove($name)
+    {
+        unset($this->extensions[$name]);
+    }
 }