All page classes must extend Zend\Navigation\Page\AbstractPage, and will thus share a common set of features and properties. Most notably they share the options in the table below and the same initialization process.
Option keys are mapped to set methods. This means that the option order maps to the method setOrder(), and reset_params maps to the method setResetParams(). If there is no setter method for the option, it will be set as a custom property of the page.
Read more on extending Zend\Navigation\Page\AbstractPage in Creating custom page types.
Note
Custom properties
All pages support setting and getting of custom properties by use of the magic methods __set($name, $value), __get($name), __isset($name) and __unset($name). Custom properties may have any value, and will be included in the array that is returned from $page->toArray(), which means that pages can be serialized/deserialized successfully even if the pages contains properties that are not native in the page class.
Both native and custom properties can be set using $page->set($name, $value) and retrieved using $page->get($name), or by using magic methods.
This example shows how custom properties can be used.
1 2 3 4 5 6 7 8 9 | $page = new Zend\Navigation\Page\Mvc();
$page->foo = 'bar';
$page->meaning = 42;
echo $page->foo;
if ($page->meaning != 42) {
// action should be taken
}
|
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.