false) * @RouteParam("methods" => [ "GET", "POST", "DELETE" ]) */ trait ControllerTrait { public Session $session; public ? Picea\Picea $picea; public MailerInterface $mailer; public function __construct(? Picea\Picea $picea, Session $session/*, MailerInterface $mailer*/) { $this->picea = $picea; $this->session = $session; // $this->mailer = $mailer; } public function renderView(string $view, ?array $variables = null) : ResponseInterface { return static::renderHtml( $this->picea->renderHtml($view, $variables ?? [], $this) ); } public function renderDocumentation(string $filename) : ResponseInterface { return $this->renderMarkdown( file_get_contents(getenv("PROJECT_PATH") . "/meta/doc/$filename.md") ); } protected function redirect(string $url, int $code = 302, array $headers = []) { return new RedirectResponse($url, $code, $headers); } public static function renderText(string $html, int $code = 200, array $headers = []) : ResponseInterface { return new TextResponse($html, $code, $headers); } public static function renderHtml(string $html, int $code = 200, array $headers = []) : ResponseInterface { return new HtmlResponse($html, $code, $headers); } public static function renderJson(array $data, int $code = 200, array $headers = []) : ResponseInterface { return new JsonResponse($data, $code, $headers); } }