interface ContainerInterface

Same name in other branches
  1. 9 core/lib/Drupal/Component/DependencyInjection/ContainerInterface.php \Drupal\Component\DependencyInjection\ContainerInterface
  2. 11.x core/lib/Drupal/Component/DependencyInjection/ContainerInterface.php \Drupal\Component\DependencyInjection\ContainerInterface

The interface for Drupal service container classes.

This interface extends Symfony's ContainerInterface and adds methods for managing mappings of instantiated services to its IDs.

Hierarchy

  • interface \Drupal\Component\DependencyInjection\ContainerInterface extends \Symfony\Component\DependencyInjection\ContainerInterface

Expanded class hierarchy of ContainerInterface

All classes that implement ContainerInterface

3 files declare their use of ContainerInterface
ChainedFastBackendFactoryTest.php in core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendFactoryTest.php
ContainerBuilder.php in core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
PluginExistsConstraintTest.php in core/tests/Drupal/Tests/Core/Plugin/PluginExistsConstraintTest.php

File

core/lib/Drupal/Component/DependencyInjection/ContainerInterface.php, line 13

Namespace

Drupal\Component\DependencyInjection
View source
interface ContainerInterface extends BaseContainerInterface {
    
    /**
     * Gets all defined service IDs.
     *
     * @return array
     *   An array of all defined service IDs.
     */
    public function getServiceIds();
    
    /**
     * Collect a mapping between service to ids.
     *
     * @return array
     *   Service ids keyed by a unique hash.
     *
     * @deprecated in drupal:9.5.1 and is removed from drupal:11.0.0. Use the
     *   'Drupal\Component\DependencyInjection\ReverseContainer' service instead.
     *
     * @see https://www.drupal.org/node/3327942
     */
    public function getServiceIdMappings() : array;
    
    /**
     * Generate a unique hash for a service object.
     *
     * @param object $object
     *   Object needing a unique hash.
     *
     * @return string
     *   A unique hash identifying the object.
     *
     * @deprecated in drupal:9.5.1 and is removed from drupal:11.0.0. Use the
     *   'Drupal\Component\DependencyInjection\ReverseContainer' service instead.
     *
     * @see https://www.drupal.org/node/3327942
     */
    public function generateServiceIdHash(object $object) : string;

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overrides
ContainerInterface::generateServiceIdHash Deprecated public function Generate a unique hash for a service object.
ContainerInterface::getServiceIdMappings Deprecated public function Collect a mapping between service to ids.
ContainerInterface::getServiceIds public function Gets all defined service IDs. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.