eZ Community » Blogs » eZ » Migrating from eZ Publish 4 to eZ...

By

Łukasz Serwatka

Migrating from eZ Publish 4 to eZ Publish 5: basic concepts

Tuesday 17 December 2013 3:21:41 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Architecturally, eZ Publish 5 is not a simple evolution but a revolution. eZ Publish 5 is based on the Symfony2 PHP framework and completely changes how you develop an eZ Publish website in a powerful and fun way. All versions of eZ Publish 5 take a dual-kernel approach that enables developers to work in both the “new stack” and the “legacy stack” at the same time. This ensures backwards compatibility and helps make the migration process to the new stack as smooth as possible.

This blog series is for existing eZ Publish 4 (or eZ Publish 5 legacy stack) users who are familiar with key eZ Publish concepts and are looking at migrating to the new stack in eZ Publish 5. In this series, we will explore how to migrate your legacy stack extensions to the new stack. We will explain the core new concepts and highlight the differences when compared to the legacy stack.

Preparation: the big picture

Before we dive into the technical details, let's consider the big picture of a migration to the new stack. The preparation phase is extremely important, as it helps to identify potential issues and answer important questions. Here are five key factors to consider for every migration process:

  • Drivers for migration (challenges, requirements): Why are you migrating and what do you need in order to be successful?
  • Inventory of current environment: Create a detailed summary of the current site and its extensions in order to understand the scope of the migration effort.
  • Migration service provider: If you do not have the migration skills and staff in-house, who has the resources to help you perform the migration?
  • Migration effort estimate: The estimate depends on many factors such as existing functionality, database complexity, and more. A migration service provider can help you build an estimate.
  • Training requirements: Change management can equip all users and developers of the website to be comfortable with the migration process and the post-migration state. This can range from training to deeply involving key users in the migration process.

To help you take an inventory of the current site, here are some elements to focus on:

  • External storage (custom tables)
  • Configuration (INI settings overrides)
  • Command line scripts
  • Template overrides
  • Datatypes
  • Edit handlers
  • Workflow events
  • AJAX calls
  • Translations
  • Editorial interfaces

We have to identify which elements can be natively implemented in the new stack and which ones still require the legacy stack. Not all legacy features are available in eZ Publish 5 yet, and it is an ongoing process to fill in the gaps. At the end of this post, we'll provide a list of eZ Publish 5 / new stack supported extension points as of eZ Publish 5.2.

New concepts

With the introduction of Symfony2 as a core component of the eZ Publish 5 architecture as well as a whole new set of public APIs, it is very important to become familiar with the new concepts. The following matrix compares the major concepts of the legacy and new stacks:

eZ Publish 4.x 

eZ Publish 5.x

Module Controller; extends eZ\Bundle\EzPublishCoreBundle\Controller
Action The method on the Controller to execute.
View A (Twig) template that displays the result of the Action.
eZ Publish templates Twig is the new template engine
{fetch()} template function

Replaced with:

Extension Bundle
Command line scripts ezpublish/console component for creating command line interfaces
INI settings YAML configurations
Kernel API using eZContentObjectTreeNode, eZContentObject, and so on

New public API accessible via a service provider; example:

$this->getRepository()->getLocationService()

In eZ Publish 5 we have introduced a more intuitive naming convention for key system elements:

eZ Publish 4.x

eZ Publish 5.x

(Content) class Content type
(Content) class group Content type group
(Content) class attribute Field definition
(Content) object Content (meta information is “content info”)
(Content object) version Version info
(Content object) attribute Field
(Content object) attribute content Field value
Datatype Field type
Node Location

Twig is the default template engine in eZ Publish 5. Here is a comparison of how to implement some of the most commonly used functionality:

eZ Publish 4.x

eZ Publish 5.x

{$node.name|wash()}, {$object.name|wash()} {{ ez_content_name( content ) }}
{if $node.data_map.author.has_content}{/if} {% if not ez_is_field_empty( content, 'author' ) %}{% endif %}
{attribute_view_gui attribute=$node.data_map.author} {{ ez_render_field( content, 'author' ) }}
{attribute_view_gui attribute=$node.data_map.location param1=value param2=value} {{ ez_render_field( content, 'location', {'parameters': {'param1': 'value', 'param2': 'value' }} ) }}
{include 'design:footer/address.tpl' node=$node} {% include "YourBundle:footer:address.html.twig" with {'content': content} %}
(see the documentation on bundle inheritance)
{$node.url_alias|ezurl()} {{ path( location ) }}{{ path( “ez_urlalias”, {“locationId”: content.contentInfo.mainLocationId} ) }}
{def $image_variation = $node.data_map.image.content['gallery']} {% set image_variation = ez_image_alias( content.getField( 'image' ), content.versionInfo, 'gallery' ) %}
(note that ez_image_alias requires you to send the version object)
{$image_variation.url|ezroot} {{ asset( image_variation.uri ) }}
{'Latest News'|i18n('design/ezdemo/footer')} {{ 'Latest News'|trans }}{{ message|trans({'%name%': 'Latest News'}, "context") }}
{$node.object.published|l10n(shortdatetime)} {{ location.contentInfo.publishedDate|localizeddate( 'short', 'short', app.request.locale ) }}
(see the localizeddate documentation)
{foreach $attribute.content.author_list as $author}
{$author.name|wash()}{delimiter},{/delimiter}
{/foreach}

{% for author in field.value.authors %}
{{ author.name }}{% if not loop.last %}, {% endif %}

{% endfor %}

Supported extension points as of eZ Publish 5.2

The following is a list of extension points in eZ Publish 5.2. For more information, please see the documentation

  • Field types (with or without custom tables)
  • Templates (view providers for content, locations and blocks [since eZ Publish 5.1])
  • Services (using the persistence API)
  • Controllers & actions (accessed through routes)
  • REST Server
  • Signals and slots
  • Events (PostSiteAccessMatchEvent, PreContentViewEvent, APIContentExceptionEvent)
    • See eZ/Publish/Core/MVC/Legacy/LegacyEvents.php and eZ/Publish/Core/MVC/Symfony/MVCEvents.php

Summary

eZ Publish 5 is a big step forward that is a lot of fun to work with, but it comes with some new concepts. In this first part of a blog post series about migrating from the legacy stack to the new stack, we covered the migration preparation process and listed the new concepts and new naming conventions. In the next part we will look closer at the eZ Publish 5 bundle system and some tools that will help you in extending the new stack.

Proudly Developed with from