public function load404Content($file) { $contentDir = $this->getConfig('content_dir'); $contentDirLength = strlen($contentDir); if (substr($file, 0, $contentDirLength) === $contentDir) { $errorFileDir = substr($file, $contentDirLength); while ($errorFileDir !== '.') { $errorFileDir = dirname($errorFileDir); $errorFile = $errorFileDir . '/404' . $this->getConfig('content_ext'); if (file_exists($this->getConfig('content_dir') . $errorFile)) { return $this->loadFileContent($this->getConfig('content_dir') . $errorFile); } } } elseif (file_exists($this->getConfig('content_dir') . '404' . $this->getConfig('content_ext'))) { // provided that the requested file is not in the regular // content directory, fallback to Pico's global `404.md` return $this->loadFileContent($this->getConfig('content_dir') . '404' . $this->getConfig('content_ext')); } $errorFile = $this->getConfig('content_dir') . '404' . $this->getConfig('content_ext'); throw new RuntimeException('Required "' . $errorFile . '" not found'); }