public function send() { $this->sendHeaders(); $this->sendContent(); if (Profiler::getState()) { echo Profiler::getInstance()->getProfilerHTMLPanel(); } }
public function __invoke(Request $request) { $initTime = microtime(true); $fileParser = FileParserFactory::getParser(YAMLParser::FILE_EXTENSION); $servicesContainer = new ServicesContainer($fileParser); $this->container = $servicesContainer; if (Profiler::getState()) { Profiler::getInstance()->setContainer($this->container); } $routingFile = $this->configurationsDirectoryPath . '/routing.' . $this->generalConfigurations['routingFileExtension']; $routing = $this->container->getService('routing'); /** @var RouteControllerInformation $routeControllerInformation */ $routeControllerInformation = $routing->parseRoute($request, $routingFile); $controllerClassName = $routeControllerInformation->getClassName(); $controllerCallableMethod = $routeControllerInformation->getCallableMethod(); $controller = new $controllerClassName(); if ($this->controllerIsChildOfNightController($controller)) { /** @var NightController $controller */ $controller->setServicesContainer($servicesContainer); } /** @var Response $response */ if ($this->controllerNeedsRequest($controllerClassName, $controllerCallableMethod)) { $response = $controller->{$controllerCallableMethod}($request); } else { $response = $controller->{$controllerCallableMethod}(); } if (is_null($response)) { InvalidResponse::throwDefault(); } $endTime = microtime(true); if (Profiler::getState()) { $executionTime = $this->calcExecutionDuration($initTime, $endTime); Profiler::getInstance()->setResponseStatus($response->getStatus()); Profiler::getInstance()->setExecutionDuration($executionTime); } return $response; }