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\EventCode
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;
}