{"record":{"id":"be6698eec67234f6","repo":"getgrav/grav","slug":"grav-framework-flex-pages-traits-pagelegacytrait-be6698","errorCode":null,"errorMessage":"Grav\\Framework\\Flex\\Pages\\Traits\\PageLegacyTrait::file(): Not Implemented","messagePattern":"Grav\\\\Framework\\\\Flex\\\\Pages\\\\Traits\\\\PageLegacyTrait::file\\(\\): Not Implemented","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php","lineNumber":261,"sourceCode":"            'content' => $this->_content,\n            'content_meta' => $this->_content_meta\n        ];\n\n        $cache = $this->getCache('render');\n        $key = md5($this->getCacheKey() . '-content');\n\n        $cache->set($key, $value);\n    }\n\n    /**\n     * Get file object to the page.\n     *\n     * @return MarkdownFile|null\n     */\n    public function file(): ?MarkdownFile\n    {\n        // TODO:\n        throw new RuntimeException(__METHOD__ . '(): Not Implemented');\n    }\n\n    /**\n     * Prepare move page to new location. Moves also everything that's under the current page.\n     *\n     * You need to call $this->save() in order to perform the move.\n     *\n     * @param PageInterface $parent New parent page.\n     * @return $this\n     */\n    public function move(PageInterface $parent)\n    {\n        if ($this->route() === $parent->route()) {\n            throw new RuntimeException('Failed: Cannot set page parent to self');\n        }\n        $rawRoute = $this->rawRoute();\n        if ($rawRoute && Utils::startsWith($parent->rawRoute(), $rawRoute)) {\n            throw new RuntimeException('Failed: Cannot set page parent to a child of current page');","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php#L243-L279","documentation":"The legacy Page API exposes file() to get the MarkdownFile instance behind a page, but Flex pages are not backed by a single file object exposed this way, so PageLegacyTrait::file() always throws 'Not Implemented'. Flex page storage may be multi-file, database-backed, or formatted differently, so the one-file abstraction does not hold.","triggerScenarios":"Plugin code calling $page->file()->markdown() or using file() to read/modify the raw markdown of a page obtained from Flex Pages; error handlers or admin themes walking pages and touching ->file().","commonSituations":"Legacy plugins doing direct file manipulation (mtime checks, markdown rewriting) against PageInterface while the site runs Flex Pages; custom workflows that assume pages == files.","solutions":["Use the storage layer instead: $page->getFlexDirectory()->getStorage()->readRaw($page->getStorageKey()) when raw access is needed.","Use property access ($page->markdown(), $page->raw()) for content rather than the file object.","Branch on instanceof FlexPageObject before calling file() in shared code paths."],"exampleFix":"// before\n$markdownFile = $page->file(); // throws for Flex pages\n\n// after\n$raw = $page->getFlexDirectory()->getStorage()->readRaw($page->getStorageKey());","handlingStrategy":"fallback","validationCode":"// Route raw-file access away from the legacy API on Flex pages\nif ($page instanceof \\Grav\\Framework\\Flex\\Pages\\FlexPageObject) {\n    $raw = $page->getFlexDirectory()->getStorage()->readRaw($page->getStorageKey());\n} else {\n    $file = $page->file();\n}","typeGuard":"function isFlexPage(\\Grav\\Common\\Page\\Interfaces\\PageInterface $page): bool\n{\n    return $page instanceof \\Grav\\Framework\\Flex\\Pages\\FlexPageObject;\n}","tryCatchPattern":null,"preventionTips":["Use property access ($page->markdown()) or flex storage readRaw() instead of ->file().","Assume Flex pages are not 1:1 with files; design plugins against the storage abstraction.","Gate every ->file() call in shared code with an instanceof FlexPageObject branch."],"tags":["grav","flex-pages","legacy-api","not-implemented","filesystem"],"backgroundTag":"unsupported-legacy-api","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}