db = $db; } // ── Factory ─────────────────────────────────────────────────────────────── /** * Convenience factory: loads the Database singleton and returns a ready * controller instance. */ public static function create(): self { require_once APP_ROOT . '/src/Database.php'; return new self(Database::getInstance()); } // ── Main entry point ───────────────────────────────────────────────────── /** * Process the current request. * * On success returns an array of view variables. * On failure (missing id, thesis not found) sends a redirect and exits. * * @return array */ public function handle(): array { $thesisId = isset($_GET['id']) ? (int) $_GET['id'] : 0; if ($thesisId <= 0) { $this->redirectHome(); } try { $data = $this->db->getThesisById($thesisId); } catch (Exception $e) { error_log('TfeController: ' . $e->getMessage()); $this->redirectHome(); } if (empty($data)) { $this->redirectHome(); } // Access type (1 = open, 2 = restricted, 3 = forbidden) $accessTypeId = $this->db->getThesisAccessTypeId($thesisId) ?? 1; $isInterdit = ($accessTypeId === 3); // Caption (WebVTT) files — N-th VTT is paired with the N-th