Grav\Common\Page\Header class

I can get the header array from the Page\Page::header() method, but it doesn’t return an actual Page\Header object. I want to use the get/set methods of the Page\Header class, but can’t find an example of being able to do this. I can work around it, but I’d like to avoid manually exploding the dot notation. How do I get a Page\Header object for the current page?

I apologize for low-level questions like this. I’m not a PHP native. Thanks!

I’m trying:

$page = $this->grav['page'];
$header = $page->header();
$result = $header->get('some.key.or.other');

But I get the following error
Call to undefined method stdClass::get()

I ended up with the following:

$page = $this->grav['page'];
$header = $page->header();
$header = new \Grav\Common\Page\Header((array) $header);
$header->set('metadata.some.nested', 'value');
$page->header($header->items);

I was going to suggest the same :slight_smile: