/** * @param string $className The name of a class that implements {@see ComponentPropertiesInterface} * @throws ReflectionException */ function __construct($className) { if (!implementsInterface($className, ComponentPropertiesInterface::class)) { throw new ReflectionException("Class %s does not implement %s", Debug::formatClassName($className), Debug::formatClassName(ComponentPropertiesInterface::class)); } $this->name = $className; }
/** * ReflectionPropertyException constructor. * @param string $className * @param string $propertyName * @param string $message * @param array ...$args */ public function __construct($className, $propertyName, $message, ...$args) { array_push($args, Debug::formatClassName($className), $propertyName); parent::__construct(sprintf("{$message}.<p>Property %s-><kbd>%s</kbd>.", ...$args)); }
private function assertContext() { if (!$this->context) { throw new ComponentException($this, sprintf("Can't render the component's template because the rendering context is not set.\n<p>See <kbd>%s</kbd>", Debug::formatClassName(RenderableInterface::class))); } }
/** * Performs the main execution sequence. * * @param ServerRequestInterface $request * @param ResponseInterface $response * @param callable $next * @return ResponseInterface * @throws FatalException * @throws FileException * @throws FlashMessageException */ function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { if (!$this->kernelSettings) { throw new FatalException("Class <kbd class=type>" . get_class($this) . "</kbd>'s constructor forgot to call <kbd>parent::__construct()</kbd>"); } $this->request = $request; $this->response = $response; $this->redirection->setRequest($request); $this->currentLink = $this->navigation->currentLink(); $this->navigation->getCurrentTrail(); if (!$this->indexPage && $this->autoRedirectUp && $this->currentLink && ($parent = $this->currentLink->parent())) { $this->indexPage = $parent->url(); } // remove page number parameter $this->URI_noPage = preg_replace('#&?' . $this->kernelSettings->pageNumberParam . '=\\d*#', '', $this->request->getUri()->getPath()); $this->URI_noPage = preg_replace('#\\?$#', '', $this->URI_noPage); $this->initialize(); //custom setup $this->modelController->setRequest($request); $this->model(); $this->modelController->handleRequest(); $this->model = $this->modelController->getModel(); switch ($this->request->getMethod()) { /** @noinspection PhpMissingBreakStatementInspection */ case 'POST': // Perform the requested action. $res = $this->doFormAction(); if ($res) { if (!$res instanceof ResponseInterface) { throw new FatalException(sprintf("Invalid HTTP response type: %s<p>Expected: <kbd>%s</kbd>", Debug::typeInfoOf($res), Debug::formatClassName(ResponseInterface::class))); } $response = $res; } if (!$this->renderOnAction) { if (!$res) { $response = $this->autoRedirect(); } break; } // Fall through. // Fall through. case 'GET': // Render the component. $out = $this->getRendering(); $response->getBody()->write($out); } $this->finalize($response); return $response; }