Page::__set()

Sets a page property.

Table of Contents
  1. Description
  2. Example

Description

Page::__set(string $key, mixed $value): void;

This method will be called when a public property is not available on class Page, but you still want to set a certain value on that property. This action will not create a new property on the page object as when you set a new property on a stdClass object. Instead, it will register a new page data item which can be treated as other native page data that comes from the page instantiation.

Example

$page = new Page(null, [
    'content' => '<p>Page content.</p>',
    'description' => 'Page description.',
    'title' => 'Page Title'
]);

echo $page->stack; // Returns `null`

$page->stack = 10;

echo $page->stack; // Returns `10`

Hook::set('page.stack', function ($value) {
    return ($value ?? 0) + 1;
});

echo $page->stack; // Returns `11`

$page->stack = 2;

echo $page->stack; // Returns `3`

Page::__set()

Sets a page property.

Page::size()

Gets the file sizes in human readable string format.