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;
*/
protected $canonicalNames;
+ /**
+ * @var \Zend\Feed\Reader\ExtensionManagerInterface|\Zend\Feed\Writer\ExtensionManagerInterface
+ */
+ protected $standalone;
+
/**
* Constructs a ZfExtensionManagerSfContainer object.
*
* {@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);
}
/**
$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();
+ }
+
}