currentRequest = $currentRequest; $this->cloner = new VarCloner; $this->cloner->setMaxItems(0); } /** * Get the context. * * @return array|null */ public function getContext(): ?array { if ($this->currentRequest === null) { return null; } $controller = null; if ($route = $this->currentRequest->route()) { $controller = $route->controller; if (! $controller && ! is_string($route->action['uses'])) { $controller = $route->action['uses']; } } return [ 'uri' => $this->currentRequest->getUri(), 'method' => $this->currentRequest->getMethod(), 'controller' => $controller ? $this->cloner->cloneVar(class_basename($controller)) : $controller, 'identifier' => spl_object_hash($this->currentRequest), ]; } }