{"record":{"id":"e54524aebb8cf619","repo":"getgrav/grav","slug":"grav-framework-flex-pages-traits-pagelegacytrait","errorCode":null,"errorMessage":"Grav\\Framework\\Flex\\Pages\\Traits\\PageLegacyTrait::init(): Not Implemented","messagePattern":"Grav\\\\Framework\\\\Flex\\\\Pages\\\\Traits\\\\PageLegacyTrait::init\\(\\): Not Implemented","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php","lineNumber":61,"sourceCode":" */\ntrait PageLegacyTrait\n{\n    /** @var array|null */\n    private $_content_meta;\n    /** @var array|null */\n    private $_metadata;\n\n    /**\n     * Initializes the page instance variables based on a file\n     *\n     * @param  SplFileInfo $file The file information for the .md file that the page represents\n     * @param  string|null $extension\n     * @return $this\n     */\n    public function init(SplFileInfo $file, $extension = null): never\n    {\n        // TODO:\n        throw new RuntimeException(__METHOD__ . '(): Not Implemented');\n    }\n\n    /**\n     * Gets and Sets the raw data\n     *\n     * @param  string|null $var Raw content string\n     * @return string      Raw content string\n     */\n    public function raw($var = null): string\n    {\n        if (null !== $var) {\n            // TODO:\n            throw new RuntimeException(__METHOD__ . '(string): Not Implemented');\n        }\n\n        $storage = $this->getFlexDirectory()->getStorage();\n        if (method_exists($storage, 'readRaw')) {\n            return $storage->readRaw($this->getStorageKey());","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php#L43-L79","documentation":"Flex pages implement the legacy PageInterface only partially; PageLegacyTrait::init() (which initializes a page from an SplFileInfo for a .md file) is intentionally not implemented for Flex pages and throws this RuntimeException. The legacy Page lifecycle does not apply to FlexPageObject, which gets its data from Flex storage instead of a single markdown file.","triggerScenarios":"Plugin/theme code calling $page->init($file) on a page obtained from the Flex Pages directory; migrations that instantiate pages the legacy way while the flex-pages architecture is active; generic code that accepts PageInterface and calls init() unconditionally.","commonSituations":"Enabling the Flex Pages architecture while running legacy plugins built against Grav's classic Page class; scaffolding/import scripts reusing legacy page-bootstrapping code.","solutions":["Remove the init() call for Flex pages; they are already initialized when fetched via $book->getIndex()/getObject().","Branch on type before using legacy APIs: if ($page instanceof FlexPageObject) { /* flex path */ } else { $page->init($file); }.","Replace legacy file-based creation with flex storage: $directory->createObject($data, $key)->save().","If the plugin is third-party, check for a Flex-compatible release or patch out the init() call."],"exampleFix":"// before\n$page->init($file);\n\n// after\nif ($page instanceof \\Grav\\Framework\\Flex\\Pages\\FlexPageObject) {\n    // Flex page: already initialized from storage.\n} else {\n    $page->init($file);\n}","handlingStrategy":"fallback","validationCode":"// Only run the legacy init lifecycle on non-flex pages\nif (!$page instanceof \\Grav\\Framework\\Flex\\Pages\\FlexPageObject) {\n    $page->init($file);\n}","typeGuard":"use Grav\\Framework\\Flex\\Pages\\FlexPageObject;\n\nfunction isFlexPage(\\Grav\\Common\\Page\\Interfaces\\PageInterface $page): bool\n{\n    return $page instanceof FlexPageObject;\n}","tryCatchPattern":null,"preventionTips":["Treat Flex pages as pre-initialized: fetch via the flex directory, never init() them.","Branch shared code on instanceof FlexPageObject before legacy lifecycle calls.","Audit legacy Page plugins when enabling the Flex Pages architecture."],"tags":["grav","flex-pages","legacy-api","not-implemented"],"backgroundTag":"unsupported-legacy-api","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}