Mercurial > hg > isophonics-drupal-site
diff core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line diff
--- a/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php Tue Jul 10 15:07:59 2018 +0100 +++ b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php Thu Feb 28 13:21:36 2019 +0000 @@ -4,6 +4,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Zend\Feed\Reader\ExtensionManagerInterface as ReaderManagerInterface; use Zend\Feed\Writer\ExtensionManagerInterface as WriterManagerInterface; @@ -49,6 +50,11 @@ protected $canonicalNames; /** + * @var \Zend\Feed\Reader\ExtensionManagerInterface|\Zend\Feed\Writer\ExtensionManagerInterface + */ + protected $standalone; + + /** * Constructs a ZfExtensionManagerSfContainer object. * * @param string $prefix @@ -62,14 +68,25 @@ * {@inheritdoc} */ public function get($extension) { - return $this->container->get($this->prefix . $this->canonicalizeName($extension)); + try { + return $this->container->get($this->prefix . $this->canonicalizeName($extension)); + } + catch (ServiceNotFoundException $e) { + if ($this->standalone && $this->standalone->has($extension)) { + return $this->standalone->get($extension); + } + throw $e; + } } /** * {@inheritdoc} */ public function has($extension) { - return $this->container->has($this->prefix . $this->canonicalizeName($extension)); + if ($this->container->has($this->prefix . $this->canonicalizeName($extension))) { + return TRUE; + } + return $this->standalone && $this->standalone->has($extension); } /** @@ -102,4 +119,14 @@ $this->container = $container; } + /** + * @param $class + */ + public function setStandalone($class) { + if (!is_subclass_of($class, ReaderManagerInterface::class) && !is_subclass_of($class, WriterManagerInterface::class)) { + throw new \RuntimeException("$class must implement Zend\Feed\Reader\ExtensionManagerInterface or Zend\Feed\Writer\ExtensionManagerInterface"); + } + $this->standalone = new $class(); + } + }