...
Info | ||
---|---|---|
| ||
Read Intro for eZ Publish 4.x/3.x developers to have an overview of common concepts and terminology changes. |
Table of Contents |
---|
Legacy Mode
Legacy mode is a specific configuration mode where eZ Publish's behavior is the closest to v4.x. It might be used in some very specific use cases, such as running the admin interface.
What it does
- Still runs through the whole Symfony kernel. As such, Symfony services can still be accessed from legacy stack.
- Disables the default router (standard Symfony routes won't work in this mode)
- Disables the UrlAliasRouter. As such, the ViewController will be bypassed.
What it doesn't do
- Increase performance. Legacy mode is actually painful for performances since it won't use the HttpCache mechanism.
Tip |
---|
In a migration context, using Legacy Mode is never a good option as it prevents all the performance goodness (e.g. Http Cache) to work. |
Allowing Symfony routes to work
As of eZ Publish 5.2, Symfony routes are also disabled in legacy mode, which implies admin interface as well.
If for some reason you need a Symfony route to work, you add it to a whitelist :
Code Block |
---|
ezpublish:
router:
default_router:
# Routes that are allowed when legacy_mode is true.
# Must be routes identifiers (e.g. "my_route_name").
# Can be a prefix, so that all routes beginning with given prefix will be taken into account.
legacy_aware_routes: ["my_route_name", "my_route_prefix_"] |
By default, _ezpublishLegacyTreeMenu
and all REST v2 (ezpublish_rest_
prefix) routes are allowed.
Legacy Template inclusion
It is possible to include old templates (.tpl) into new ones:.
Code Block | ||
---|---|---|
| ||
{# Twig template #} {# Following code will include my/old_template.tpl, exposing $someVar variable in it #} {% include "design:my/old_template.tpl" with {"someVar": "someValue"} %} |
Or if you want to include a legacy template by its path, relative to ezpublish_legacy
folder:
Code Block | ||
---|---|---|
| ||
{# Following code will include ezpublish_legacyextension/my_legacy_extension/design/standard/templates/my_old_template.tpl, exposing $someVar variable in it #}
{% include "file:extension/my_legacy_extension/design/standard/templates/my_old_template.tpl" with {"someVar": "someValue"} %} |
Template parameters
Scalar and array parameters are passed to a legacy template as-is.
...
Running legacy code
eZ Publish 5 .2 still relies on the legacy kernel (from 4.x) and runs it when needed inside an isolated PHP closure, making it sandboxed. This is available for your use as well making it possible to run some PHP code inside that sandbox through the runCallback()
method.
Code Block | ||||
---|---|---|---|---|
| ||||
<?php // Declare use statements for the classes you may need use eZINI; // Inside a controller extending eZ\Bundle\EzPublishCoreBundle\Controller $settingName = 'MySetting'; $test = array( 'oneValue', 'anotherValue' ); $myLegacySetting = $this->getLegacyKernel()->runCallback( function () use ( $settingName, $test ) { // Here you can reuse $settingName and $test variables inside the legacy context $ini = eZINI::instance( 'someconfig.ini' ); return $ini->variable( 'SomeSection', $settingName ); } ); |
...
Any route that is not declared in eZ Publish 5 .2 in an included routing.yml
and that is not a valid UrlAlias will automatically fallback to eZ Publish legacy (including admin interface).
...
Code Block | ||||
---|---|---|---|---|
| ||||
{{ render( url( 'ez_legacy', {'module_uri': '/content/view/sitemap/2'} ) ) }} |
Using eZ Publish 5
...
and Symfony features in Legacy
If for some reason you need to develop a legacy module and access to eZ Publish 5 / Symfony features (i.e. when developing an extension for admin interface), you'll be happy to know that you actually have access to all services registered in the whole framework, including bundles, through the service container.
...
Running legacy scripts and cronjobs
Noteinfo |
---|
Note: This feature has been introduced in eZ Publish 5.1. |
Warningnote | ||
---|---|---|
| ||
Running legacy scripts and cronjobs through the Symfony stack is highly recommended ! |
Legacy scripts can be executed form the Symfony CLI, by using the ezpublish:legacy:script
command, specifying the path to the script as argument.
The command will need to be executed from eZ Publish's 5 .2 root, and the path to the desired script must exist in the ezpublish_legacy
folder.
Here's a usage example:
No Format |
---|
php ezpublish/console --env=prod ezpublish:legacy:script bin/php/ezpgenerateautoloads.php |
Here we made sure to specify --env=prod, this is needed for all legacy scripts that clear cache, otherwise they will will clear dev environment cache instead of prod for Symfony stack.
If you want to access the script's help please be aware that you will need to use the newly introduced --legacy-help
option, since --help is already reserved for the CLI help.
Noteinfo |
---|
The |
...
No Format |
---|
php ezpublish/console --env=prod ezpublish:legacy:script --legacy-help bin/php/ezpgenerateautoloads.php |
...
No Format |
---|
php ezpublish/console --env=prod ezpublish:legacy:script runcronjobs.php frequent |
...