{"record":{"id":"6cd4384d4826cbfc","repo":"getgrav/grav","slug":"grav-framework-flex-pages-traits-pagelegacytrait-6cd438","errorCode":null,"errorMessage":"Grav\\Framework\\Flex\\Pages\\Traits\\PageLegacyTrait::raw(string): Not Implemented","messagePattern":"Grav\\\\Framework\\\\Flex\\\\Pages\\\\Traits\\\\PageLegacyTrait::raw\\(string\\): Not Implemented","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php","lineNumber":74,"sourceCode":"     * @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());\n        }\n\n        $array = $this->prepareStorage();\n        $formatter = new MarkdownFormatter();\n\n        return $formatter->encode($array);\n    }\n\n    /**\n     * Gets and Sets the page frontmatter\n     *\n     * @param string|null $var\n     * @return string","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php#L56-L92","documentation":"PageLegacyTrait::raw() supports reading the raw page content (it falls back to storage->readRaw() or re-encodes via MarkdownFormatter), but setting raw content — raw($var) with a non-null argument — is not implemented for Flex pages and throws this RuntimeException. Flex pages are edited through object properties and save(), not by writing the whole raw file at once.","triggerScenarios":"Calling $page->raw('# New content') on a FlexPageObject (legacy sync/import code); CLI scripts that push external markdown into pages via raw(); admin plugins using raw() to overwrite page bodies.","commonSituations":"Porting legacy import pipelines to a site running the Flex Pages architecture; third-party plugins that update page content through raw() instead of the content property.","solutions":["Write content through the property API: $page->setContent('# New content'); $page->save(); (or $page->setProperty('content', ...)).","For full-file imports, create/update the object: $directory->createObject(['content' => $raw, ...], $key)->save().","Branch on instanceof FlexPageObject in code that must serve both page types."],"exampleFix":"// before\n$page->raw(\"# Updated\\n\\nBody text\");\n\n// after\n$page->setContent(\"# Updated\\n\\nBody text\");\n$page->save();","handlingStrategy":"fallback","validationCode":null,"typeGuard":"function isFlexPage(\\Grav\\Common\\Page\\Interfaces\\PageInterface $page): bool\n{\n    return $page instanceof \\Grav\\Framework\\Flex\\Pages\\FlexPageObject;\n}","tryCatchPattern":null,"preventionTips":["Write content via $page->setContent() + save() instead of raw($string).","Use raw() (no argument) only for reading on Flex pages.","Keep raw-write code paths behind instanceof checks for hybrid sites."],"tags":["grav","flex-pages","legacy-api","not-implemented","raw-content"],"backgroundTag":"unsupported-legacy-api","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}