You are here

class ParamConverterSubscriber in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php \Drupal\Core\EventSubscriber\ParamConverterSubscriber

Event subscriber for registering parameter converters with routes.

Hierarchy

Expanded class hierarchy of ParamConverterSubscriber

1 string reference to 'ParamConverterSubscriber'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses ParamConverterSubscriber
paramconverter_subscriber in core/core.services.yml
Drupal\Core\EventSubscriber\ParamConverterSubscriber

File

core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php, line 18
Contains \Drupal\Core\EventSubscriber\ParamConverterSubscriber.

Namespace

Drupal\Core\EventSubscriber
View source
class ParamConverterSubscriber implements EventSubscriberInterface {

  /**
   * The parameter converter manager.
   *
   * @var \Drupal\Core\ParamConverter\ParamConverterManagerInterface
   */
  protected $paramConverterManager;

  /**
   * Constructs a new ParamConverterSubscriber.
   *
   * @param \Drupal\Core\ParamConverter\ParamConverterManagerInterface $param_converter_manager
   *   The parameter converter manager that will be responsible for upcasting
   *   request attributes.
   */
  public function __construct(ParamConverterManagerInterface $param_converter_manager) {
    $this->paramConverterManager = $param_converter_manager;
  }

  /**
   * Applies parameter converters to route parameters.
   *
   * @param \Drupal\Core\Routing\RouteBuildEvent $event
   *   The event to process.
   */
  public function onRoutingRouteAlterSetParameterConverters(RouteBuildEvent $event) {
    $this->paramConverterManager
      ->setRouteParameterConverters($event
      ->getRouteCollection());
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {

    // Run after \Drupal\system\EventSubscriber\AdminRouteSubscriber.
    $events[RoutingEvents::ALTER][] = array(
      'onRoutingRouteAlterSetParameterConverters',
      -220,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParamConverterSubscriber::$paramConverterManager protected property The parameter converter manager.
ParamConverterSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
ParamConverterSubscriber::onRoutingRouteAlterSetParameterConverters public function Applies parameter converters to route parameters.
ParamConverterSubscriber::__construct public function Constructs a new ParamConverterSubscriber.