getgrav/grav · error · RuntimeException
Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::raw(string…
Error message
Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::raw(string): Not Implemented
What it means
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.
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.
Example fix
// before
$page->raw("# Updated\n\nBody text");
// after
$page->setContent("# Updated\n\nBody text");
$page->save(); Defensive patterns
Strategy: fallback
Type guard
function isFlexPage(\Grav\Common\Page\Interfaces\PageInterface $page): bool
{
return $page instanceof \Grav\Framework\Flex\Pages\FlexPageObject;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::init()…
- Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::file()…
- 500
- Failed: Cannot set page parent to a child of current page
- Failed: Cannot set page parent to self
AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17).
Data as JSON: /api/errors/6cd4384d4826cbfc.
Report an issue: GitHub.
Appendix: source
Thrown at system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php:74
* @return $this
*/
public function init(SplFileInfo $file, $extension = null): never
{
// TODO:
throw new RuntimeException(__METHOD__ . '(): Not Implemented');
}
/**
* Gets and Sets the raw data
*
* @param string|null $var Raw content string
* @return string Raw content string
*/
public function raw($var = null): string
{
if (null !== $var) {
// TODO:
throw new RuntimeException(__METHOD__ . '(string): Not Implemented');
}
$storage = $this->getFlexDirectory()->getStorage();
if (method_exists($storage, 'readRaw')) {
return $storage->readRaw($this->getStorageKey());
}
$array = $this->prepareStorage();
$formatter = new MarkdownFormatter();
return $formatter->encode($array);
}
/**
* Gets and Sets the page frontmatter
*
* @param string|null $var
* @return stringView on GitHub (pinned to 6040efed04)