Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ControllerEvent.php

function ControllerEvent::setController

Parameters

array<class-string, list<object>>|null $attributes:

1 call to ControllerEvent::setController()
ControllerEvent::__construct in vendor/symfony/http-kernel/Event/ControllerEvent.php

File

vendor/symfony/http-kernel/Event/ControllerEvent.php, line 54

Class

ControllerEvent
Allows filtering of a controller callable.

Namespace

Symfony\Component\HttpKernel\Event

Code

public function setController(callable $controller, ?array $attributes = null) : void {
    if (null !== $attributes) {
        $this->attributes = $attributes;
    }
    if (isset($this->controller) && ($controller instanceof \Closure ? $controller == $this->controller : $controller === $this->controller)) {
        $this->controller = $controller;
        return;
    }
    if (null === $attributes) {
        unset($this->attributes);
    }
    if (\is_array($controller) && method_exists(...$controller)) {
        $this->controllerReflector = new \ReflectionMethod(...$controller);
    }
    elseif (\is_string($controller) && str_contains($controller, '::')) {
        $this->controllerReflector = new \ReflectionMethod(...explode('::', $controller, 2));
    }
    else {
        $this->controllerReflector = new \ReflectionFunction($controller(...));
    }
    $this->controller = $controller;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal