You are here

class ZfExtensionManagerSfContainer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php \Drupal\Component\Bridge\ZfExtensionManagerSfContainer

Defines a bridge between the ZF2 service manager to Symfony container.

Hierarchy

Expanded class hierarchy of ZfExtensionManagerSfContainer

1 file declares its use of ZfExtensionManagerSfContainer
ZfExtensionManagerSfContainerTest.php in core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php
Contains \Drupal\Tests\Component\Bridge\ZfExtensionManagerSfContainerTest.
1 string reference to 'ZfExtensionManagerSfContainer'
core.services.yml in core/core.services.yml
core/core.services.yml
2 services use ZfExtensionManagerSfContainer
feed.bridge.reader in core/core.services.yml
Drupal\Component\Bridge\ZfExtensionManagerSfContainer
feed.bridge.writer in core/core.services.yml
Drupal\Component\Bridge\ZfExtensionManagerSfContainer

File

core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php, line 17
Contains \Drupal\Component\Bridge\ZfExtensionManagerSfContainer.

Namespace

Drupal\Component\Bridge
View source
class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterManagerInterface, ContainerAwareInterface {

  /**
   * This property was based from Zend Framework (http://framework.zend.com/)
   *
   * @link      http://github.com/zendframework/zf2 for the canonical source repository
   * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
   * @license   http://framework.zend.com/license/new-bsd New BSD License
   *
   * A map of characters to be replaced through strtr.
   *
   * @var array
   *
   * @see \Drupal\Component\Bridge\ZfExtensionManagerSfContainer::canonicalizeName().
   */
  protected $canonicalNamesReplacements = array(
    '-' => '',
    '_' => '',
    ' ' => '',
    '\\' => '',
    '/' => '',
  );

  /**
   * The prefix to be used when retrieving plugins from the container.
   *
   * @var string
   */
  protected $prefix = '';

  /**
   * The service container.
   *
   * @var \Symfony\Component\DependencyInjection\ContainerInterface
   */
  protected $container;

  /**
   * A local cache of computed canonical names.
   *
   * @var string[]
   */
  protected $canonicalNames;

  /**
   * Constructs a ZfExtensionManagerSfContainer object.
   *
   * @param string $prefix
   *   The prefix to be used when retrieving plugins from the container.
   */
  public function __construct($prefix = '') {
    return $this->prefix = $prefix;
  }

  /**
   * {@inheritdoc}
   */
  public function get($extension) {
    return $this->container
      ->get($this->prefix . $this
      ->canonicalizeName($extension));
  }

  /**
   * {@inheritdoc}
   */
  public function has($extension) {
    return $this->container
      ->has($this->prefix . $this
      ->canonicalizeName($extension));
  }

  /**
   * This method was based from Zend Framework (http://framework.zend.com/)
   *
   * @link      http://github.com/zendframework/zf2 for the canonical source repository
   * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
   * @license   http://framework.zend.com/license/new-bsd New BSD License
   *
   * Canonicalize the extension name to a service name.
   *
   * @param string $name
   *   The extension name.
   *
   * @return string
   *   The service name, without the prefix.
   */
  protected function canonicalizeName($name) {
    if (isset($this->canonicalNames[$name])) {
      return $this->canonicalNames[$name];
    }

    // This is just for performance instead of using str_replace().
    return $this->canonicalNames[$name] = strtolower(strtr($name, $this->canonicalNamesReplacements));
  }

  /**
   * {@inheritdoc}
   */
  public function setContainer(ContainerInterface $container = NULL) {
    $this->container = $container;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ZfExtensionManagerSfContainer::$canonicalNames protected property A local cache of computed canonical names.
ZfExtensionManagerSfContainer::$canonicalNamesReplacements protected property This property was based from Zend Framework (http://framework.zend.com/)
ZfExtensionManagerSfContainer::$container protected property The service container.
ZfExtensionManagerSfContainer::$prefix protected property The prefix to be used when retrieving plugins from the container.
ZfExtensionManagerSfContainer::canonicalizeName protected function This method was based from Zend Framework (http://framework.zend.com/)
ZfExtensionManagerSfContainer::get public function Retrieve the extension Overrides ExtensionManagerInterface::get
ZfExtensionManagerSfContainer::has public function Do we have the extension? Overrides ExtensionManagerInterface::has
ZfExtensionManagerSfContainer::setContainer public function Sets the Container. Overrides ContainerAwareInterface::setContainer
ZfExtensionManagerSfContainer::__construct public function Constructs a ZfExtensionManagerSfContainer object.