protected function getActionReflection()
{
if ($this->actionReflection) {
return $this->actionReflection;
}
$uses = $this->route->getAction()['uses'];
// Если это строка и она содержит @, значит мы имем дело с методом контроллера.
if (is_string($uses) && str_contains($uses, '@')) {
list($controller, $action) = explode('@', $uses);
// Если нет контроллера.
if (!class_exists($controller)) {
$this->setError('uses', 'controller does not exists');
return null;
}
// Если нет метода в контроллере.
if (!method_exists($controller, $action)) {
$this->setError('uses', 'controller@method does not exists');
return null;
}
return $this->actionReflection = new \ReflectionMethod($controller, $action);
}
if (is_callable($uses)) {
return $this->actionReflection = new \ReflectionFunction($uses);
}
$this->setError('uses', 'route uses is not valid');
return null;
}