class RegisterStringTranslatorsPass

Adds services tagged 'string_translator' to the string_translation service.

Hierarchy

Expanded class hierarchy of RegisterStringTranslatorsPass

1 file declares its use of RegisterStringTranslatorsPass
CoreBundle.php in drupal/core/lib/Drupal/Core/CoreBundle.php
Definition of Drupal\Core\CoreBundle.

File

drupal/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStringTranslatorsPass.php, line 17
Contains Drupal\Core\DependencyInjection\Compiler\RegisterStringTranslatorsPass.

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class RegisterStringTranslatorsPass implements CompilerPassInterface {

  /**
   * {@inheritdoc}
   */
  public function process(ContainerBuilder $container) {
    if (!$container
      ->hasDefinition('string_translation')) {
      return;
    }
    $access_manager = $container
      ->getDefinition('string_translation');
    foreach ($container
      ->findTaggedServiceIds('string_translator') as $id => $attributes) {
      $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
      $access_manager
        ->addMethodCall('addTranslator', array(
        new Reference($id),
        $priority,
      ));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegisterStringTranslatorsPass::process public function You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface::process