Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Reader/Reader.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 7a779792577d |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
575 * @return void | 575 * @return void |
576 * @throws Exception\RuntimeException if unable to resolve Extension class | 576 * @throws Exception\RuntimeException if unable to resolve Extension class |
577 */ | 577 */ |
578 public static function registerExtension($name) | 578 public static function registerExtension($name) |
579 { | 579 { |
580 $feedName = $name . '\Feed'; | 580 if (! static::hasExtension($name)) { |
581 $entryName = $name . '\Entry'; | 581 throw new Exception\RuntimeException(sprintf( |
582 'Could not load extension "%s" using Plugin Loader.' | |
583 . ' Check prefix paths are configured and extension exists.', | |
584 $name | |
585 )); | |
586 } | |
587 | |
588 // Return early if already registered. | |
589 if (static::isRegistered($name)) { | |
590 return; | |
591 } | |
592 | |
582 $manager = static::getExtensionManager(); | 593 $manager = static::getExtensionManager(); |
583 if (static::isRegistered($name)) { | 594 |
584 if ($manager->has($feedName) || $manager->has($entryName)) { | 595 $feedName = $name . '\Feed'; |
585 return; | |
586 } | |
587 } | |
588 | |
589 if (! $manager->has($feedName) && ! $manager->has($entryName)) { | |
590 throw new Exception\RuntimeException('Could not load extension: ' . $name | |
591 . ' using Plugin Loader. Check prefix paths are configured and extension exists.'); | |
592 } | |
593 if ($manager->has($feedName)) { | 596 if ($manager->has($feedName)) { |
594 static::$extensions['feed'][] = $feedName; | 597 static::$extensions['feed'][] = $feedName; |
595 } | 598 } |
599 | |
600 $entryName = $name . '\Entry'; | |
596 if ($manager->has($entryName)) { | 601 if ($manager->has($entryName)) { |
597 static::$extensions['entry'][] = $entryName; | 602 static::$extensions['entry'][] = $entryName; |
598 } | 603 } |
599 } | 604 } |
600 | 605 |
670 static::registerExtension('Atom'); | 675 static::registerExtension('Atom'); |
671 static::registerExtension('Slash'); | 676 static::registerExtension('Slash'); |
672 static::registerExtension('WellFormedWeb'); | 677 static::registerExtension('WellFormedWeb'); |
673 static::registerExtension('Thread'); | 678 static::registerExtension('Thread'); |
674 static::registerExtension('Podcast'); | 679 static::registerExtension('Podcast'); |
680 | |
681 // Added in 2.10.0; check for it conditionally | |
682 static::hasExtension('GooglePlayPodcast') | |
683 ? static::registerExtension('GooglePlayPodcast') | |
684 : trigger_error( | |
685 sprintf( | |
686 'Please update your %1$s\ExtensionManagerInterface implementation to add entries for' | |
687 . ' %1$s\Extension\GooglePlayPodcast\Entry and %1$s\Extension\GooglePlayPodcast\Feed.', | |
688 __NAMESPACE__ | |
689 ), | |
690 \E_USER_NOTICE | |
691 ); | |
675 } | 692 } |
676 | 693 |
677 /** | 694 /** |
678 * Utility method to apply array_unique operation to a multidimensional | 695 * Utility method to apply array_unique operation to a multidimensional |
679 * array. | 696 * array. |
690 foreach ($array as &$value) { | 707 foreach ($array as &$value) { |
691 $value = unserialize($value); | 708 $value = unserialize($value); |
692 } | 709 } |
693 return $array; | 710 return $array; |
694 } | 711 } |
712 | |
713 /** | |
714 * Does the extension manager have the named extension? | |
715 * | |
716 * This method exists to allow us to test if an extension is present in the | |
717 * extension manager. It may be used by registerExtension() to determine if | |
718 * the extension has items present in the manager, or by | |
719 * registerCoreExtension() to determine if the core extension has entries | |
720 * in the extension manager. In the latter case, this can be useful when | |
721 * adding new extensions in a minor release, as custom extension manager | |
722 * implementations may not yet have an entry for the extension, which would | |
723 * then otherwise cause registerExtension() to fail. | |
724 * | |
725 * @param string $name | |
726 * @return bool | |
727 */ | |
728 protected static function hasExtension($name) | |
729 { | |
730 $feedName = $name . '\Feed'; | |
731 $entryName = $name . '\Entry'; | |
732 $manager = static::getExtensionManager(); | |
733 | |
734 return $manager->has($feedName) || $manager->has($entryName); | |
735 } | |
695 } | 736 } |