Chris@0: '', '_' => '', ' ' => '', '\\' => '', '/' => '']; Chris@0: Chris@0: /** Chris@0: * The prefix to be used when retrieving plugins from the container. Chris@0: * Chris@0: * @var string Chris@0: */ Chris@0: protected $prefix = ''; Chris@0: Chris@0: /** Chris@0: * The service container. Chris@0: * Chris@0: * @var \Symfony\Component\DependencyInjection\ContainerInterface Chris@0: */ Chris@0: protected $container; Chris@0: Chris@0: /** Chris@0: * A local cache of computed canonical names. Chris@0: * Chris@0: * @var string[] Chris@0: */ Chris@0: protected $canonicalNames; Chris@0: Chris@0: /** Chris@0: * Constructs a ZfExtensionManagerSfContainer object. Chris@0: * Chris@0: * @param string $prefix Chris@0: * The prefix to be used when retrieving plugins from the container. Chris@0: */ Chris@0: public function __construct($prefix = '') { Chris@0: $this->prefix = $prefix; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function get($extension) { Chris@0: return $this->container->get($this->prefix . $this->canonicalizeName($extension)); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function has($extension) { Chris@0: return $this->container->has($this->prefix . $this->canonicalizeName($extension)); Chris@0: } Chris@0: Chris@0: /** Chris@0: * This method was based from Zend Framework (http://framework.zend.com/) Chris@0: * Chris@0: * @link http://github.com/zendframework/zf2 for the canonical source repository Chris@0: * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) Chris@0: * @license http://framework.zend.com/license/new-bsd New BSD License Chris@0: * Chris@0: * Canonicalize the extension name to a service name. Chris@0: * Chris@0: * @param string $name Chris@0: * The extension name. Chris@0: * Chris@0: * @return string Chris@0: * The service name, without the prefix. Chris@0: */ Chris@0: protected function canonicalizeName($name) { Chris@0: if (isset($this->canonicalNames[$name])) { Chris@0: return $this->canonicalNames[$name]; Chris@0: } Chris@0: // This is just for performance instead of using str_replace(). Chris@0: return $this->canonicalNames[$name] = strtolower(strtr($name, $this->canonicalNamesReplacements)); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setContainer(ContainerInterface $container = NULL) { Chris@0: $this->container = $container; Chris@0: } Chris@0: Chris@0: }