...
Info | ||
---|---|---|
| ||
Configuration is tightly related to the service container. |
Basic configuration handling in eZ Publish Platform is similar to what is commonly possible with Symfony. Regarding this, you can define key/value pairs in your configuration files, under the main parameters key (like in parameters.yml).
Internally and by convention, keys follow a dot syntax where the different segments follow your configuration hierarchy. Keys are usually prefixed by a namespace corresponding to your application.
Values can be anything, including arrays and deep hashes.
Info |
---|
eZ Publish Platform core configuration is prefixed by ezsettings namespace, while internal configuration (not to be used directly) is prefixed by ezpublish namespace. |
...
Dynamic configuration with the ConfigResolver
In eZ Publish, Platform it is fairly common to have different settings depending on the current siteaccess (e.g. languages, view provider configuration).
...
Available scopes are (in order of precedence) :
- global
- SiteAccess
- SiteAcces SiteAccess group
- default
It gives the opportunity to define settings for a given siteaccess, for instance, like in the legacy INI override system.
This mechanism is not limited to eZ Publish Platform internal settings (aka ezsettings namespace) and is applicable for specific needs (bundle-related, project-related, etc.).
Warning |
---|
Always prefer semantic configuration especially for internal eZ settings. |
...
In order to work with the config resolver, your dynamic settings must comply internally to with the following name format: <namespace>.<scope>.parameter.name
.
Info |
---|
The following configuration is an example of internal usage inside the code of eZ Publish Platform. |
Code Block | ||||
---|---|---|---|---|
| ||||
parameters: # Some internal configuration ezsettings.default.content.default_ttl: 60 ezsettings.ezdemo_site.content.default_ttl: 3600 # Here "myapp" is the namespace, followed by the siteaccess name as the parameter scope # Parameter "foo" will have a different value in ezdemo_site and ezdemo_site_admin myapp.ezdemo_site.foo: bar myapp.ezdemo_site_admin.foo: another value # Defining a default value, for other siteaccesses myapp.default.foo: Default value # Defining a global setting, used for all siteaccesses #myapp.global.some.setting: This is a global value |
...
Tip |
---|
Instead of injecting the whole ConfigResolver service, you may directly inject your SiteAccess-aware settings (aka dynamic settings) into your own services. |
...
Code Block | ||
---|---|---|
| ||
<?php namespace My\Cool; use eZ\Publish\Core\MVC\ConfigResolverInterface; class Service { /** * @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ private $configResolver; public function __construct( ConfigResolverInterface $configResolver ) { $this->configResolver = $configResolver; $myParam = $this->configResolver->getParameter( 'foo', 'myapp' ); } // ... } |
Custom locale configuration
...
If you need to use a custom locale they can also be configurable in ezplatform.yml
, adding them to the conversion map:
...