Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / zendframework / zend-feed / src / Reader / Reader.php
index 10189f36857c32e35913b9c3cbc4ed4597d54d03..794d44591da02e9736d00777c2ca643ca2922394 100644 (file)
@@ -577,22 +577,27 @@ class Reader implements ReaderImportInterface
      */
     public static function registerExtension($name)
     {
-        $feedName  = $name . '\Feed';
-        $entryName = $name . '\Entry';
-        $manager   = static::getExtensionManager();
-        if (static::isRegistered($name)) {
-            if ($manager->has($feedName) || $manager->has($entryName)) {
-                return;
-            }
+        if (! static::hasExtension($name)) {
+            throw new Exception\RuntimeException(sprintf(
+                'Could not load extension "%s" using Plugin Loader.'
+                . ' Check prefix paths are configured and extension exists.',
+                $name
+            ));
         }
 
-        if (! $manager->has($feedName) && ! $manager->has($entryName)) {
-            throw new Exception\RuntimeException('Could not load extension: ' . $name
-                . ' using Plugin Loader. Check prefix paths are configured and extension exists.');
+        // Return early if already registered.
+        if (static::isRegistered($name)) {
+            return;
         }
+
+        $manager   = static::getExtensionManager();
+
+        $feedName = $name . '\Feed';
         if ($manager->has($feedName)) {
             static::$extensions['feed'][] = $feedName;
         }
+
+        $entryName = $name . '\Entry';
         if ($manager->has($entryName)) {
             static::$extensions['entry'][] = $entryName;
         }
@@ -672,6 +677,18 @@ class Reader implements ReaderImportInterface
         static::registerExtension('WellFormedWeb');
         static::registerExtension('Thread');
         static::registerExtension('Podcast');
+
+        // Added in 2.10.0; check for it conditionally
+        static::hasExtension('GooglePlayPodcast')
+            ? static::registerExtension('GooglePlayPodcast')
+            : trigger_error(
+                sprintf(
+                    'Please update your %1$s\ExtensionManagerInterface implementation to add entries for'
+                    . ' %1$s\Extension\GooglePlayPodcast\Entry and %1$s\Extension\GooglePlayPodcast\Feed.',
+                    __NAMESPACE__
+                ),
+                \E_USER_NOTICE
+            );
     }
 
     /**
@@ -692,4 +709,28 @@ class Reader implements ReaderImportInterface
         }
         return $array;
     }
+
+    /**
+     * Does the extension manager have the named extension?
+     *
+     * This method exists to allow us to test if an extension is present in the
+     * extension manager. It may be used by registerExtension() to determine if
+     * the extension has items present in the manager, or by
+     * registerCoreExtension() to determine if the core extension has entries
+     * in the extension manager. In the latter case, this can be useful when
+     * adding new extensions in a minor release, as custom extension manager
+     * implementations may not yet have an entry for the extension, which would
+     * then otherwise cause registerExtension() to fail.
+     *
+     * @param string $name
+     * @return bool
+     */
+    protected static function hasExtension($name)
+    {
+        $feedName  = $name . '\Feed';
+        $entryName = $name . '\Entry';
+        $manager   = static::getExtensionManager();
+
+        return $manager->has($feedName) || $manager->has($entryName);
+    }
 }