interface ContainerInterface

Same name and namespace in other branches
  1. 10 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

1 file declares its use of ContainerInterface
ContainerBuilder.php in core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.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.