class RegisterParamConvertersPass

Registers EntityConverter services with the ParamConverterManager.

Hierarchy

Expanded class hierarchy of RegisterParamConvertersPass

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

File

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

Namespace

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

  /**
   * Adds services tagged with "paramconverter" to the param converter service.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
   *   The container to process.
   */
  public function process(ContainerBuilder $container) {
    if (!$container
      ->hasDefinition('paramconverter_manager')) {
      return;
    }
    $manager = $container
      ->getDefinition('paramconverter_manager');
    $services = array();
    foreach ($container
      ->findTaggedServiceIds('paramconverter') as $id => $attributes) {
      $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
      $services[$priority][] = new Reference($id);
    }
    krsort($services);
    foreach ($services as $priority) {
      foreach ($priority as $service) {
        $manager
          ->addMethodCall('addConverter', array(
          $service,
        ));
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegisterParamConvertersPass::process public function Adds services tagged with "paramconverter" to the param converter service. Overrides CompilerPassInterface::process