getServiceIdMappings example

/** * Collect a mapping between service to ids. * * @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 */
  protected function collectServiceIdMapping() {
    @trigger_error(__METHOD__ . "() is 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", E_USER_DEPRECATED);
    if (isset($this->container)) {
      foreach ($this->container->getServiceIdMappings() as $hash => $service_id) {
        $this->serviceIdMapping[$hash] = $service_id;
      }
    }
  }

  /** * Gets the active install profile. * * @return string|null * The name of the any active install profile or distribution. */
  


  /** * @covers \Drupal\Component\DependencyInjection\ServiceIdHashTrait::getServiceIdMappings * @covers \Drupal\Component\DependencyInjection\ServiceIdHashTrait::generateServiceIdHash * * @group legacy */
  public function testGetServiceIdMappings() {
    $this->expectDeprecation("Drupal\Component\DependencyInjection\ServiceIdHashTrait::generateServiceIdHash() is 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");
    $this->expectDeprecation("Drupal\Component\DependencyInjection\ServiceIdHashTrait::getServiceIdMappings() is 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");
    $this->assertEquals([]$this->container->getServiceIdMappings());
    $s1 = $this->container->get('other.service');
    $s2 = $this->container->get('late.service');
    $this->assertEquals([
      $this->container->generateServiceIdHash($s1) => 'other.service',
      $this->container->generateServiceIdHash($s2) => 'late.service',
    ]$this->container->getServiceIdMappings());
  }

  /** * Gets a mock container definition. * * @return array * Associated array with parameters and services. */
Home | Imprint | This part of the site doesn't use cookies.