Data assignment
You can simply pass data to any object or template with the configuration file: packages/acme/etc/config.php
The key default
provides data to all objects.
<?php
$config = [
'acme' => [
'default' => [
'default' => [
'scope' => 'I\'m available everywhere in the "acme" package',
],
],
Core_Block::TYPE => [
'default' => [
'scope' => 'I\'m available in all blocks of the "acme" package',
],
'banner' => [
'scope' => 'I\'m available in the block "banner" of the "acme" package',
],
],
],
];
The data will be available in class or template file with the getData
method or the magic getter:
<?php
$this->getData('scope');
// or
$this->getScope();
Use global configuration file to set data to packages and objects according the environment: etc/config.{MW_ENVIRONMENT}.php
<?php
$config = [
'default' => [
'default' => [
'default' => [
'scope' => 'I\'m available everywhere in all packages for the current environment',
],
],
Core_Page::TYPE => [
'default' => [
'scope' => 'I\'m available in all pages of all packages for the current environment',
],
],
Core_Block::TYPE => [
'banner' => [
'scope' => 'I\'m available in the block "banner" of all packages for the current environment',
],
],
],
];
Overload hierarchy:
- default.default.default
- default.default.{identifier}
- default.{type}.default
- default.{type}.{identifier}
- {package}.default.default
- {package}.default.{identifier}
- {package}.{type}.default
- {package}.{type}.{identifier}