Last week's sneak peek described the new interface improvements and related capabilities focusing on the editorial experience. This post looks at how the 3.0 release of eZ Platform focuses on the practical, daily aspects of developer and integrator experience. We describe the most important ones so that you can benefit from them right away.
Two new features cover an important aspect of every project: querying for content items, such as a container's children. The first is the Content Query Field Type.
Up until now, two options were available: a custom PHP controller, or the query controller. Version 3.0 ships with a new Field Type: Content Query. This enables you to add fields to your content types that return the relevant items list: the images of a gallery, the products within a category; you can think of them as dynamic relations based on the Search index.
By bringing content listing into the repository, we ensure that content structuring only happens in one place. Integrators do not need to know that the images of a gallery are the sub-items of gallery content items of type image. They can render the images field of gallery items, and focus on customizing the look and feel of it.
The second new content querying feature is a set of built-in query types. These can be used in the custom controllers, in query controllers configurations, or with the Query Field described above:
- Children, Siblings, Subtree and Ancestors for querying based on the content tree
- RelatedToContent for reverse relations
- GeoLocation for map location based data
By default, they will only return visible content items, and restrict returned items to the active content root. In addition to their own, specific parameters, they all support a common set of options:
- filtering parameters, like content_type as well as custom filters
With these two features, you can now structure every aspect of your data in one place, the repository, and retrieve them consistently from any channel: PHP, Twig, REST and GraphQL.
Improved Public API
The PHP repository API, or Public API, has been enhanced in two ways: strict typing, and proxy objects.
Strict typing fully implements strict typing as introduced with PHP 7. All services and value objects will now error out if a string is passed when an integer is expected. It will avoid errors that can be difficult to locate, and save time when developing by displaying potential mistakes directly in the IDE.
The ContentInfo, VersionInfo, Location and ContentType value objects now have new methods that give you direct access to related data: the content creator, the location's parent or children... until now, retrieving these would typically require custom controllers or code. The proxy objects will call the services transparently, without any performance hit, , and you will be able to achieve much more, directly from templates.
Note that children, ancestors and siblings will often be better implemented with a query field, as it supports pagination, sorting, and centralizes the structure's logic in one place.
Siteaccess aware global twig variables
This release makes native a feature that was provided by Jérôme Vieilledent's Core Extra bundle. It lets you define, per siteaccess, variables that are available as twig globals:
With the configuration above, when within my_siteaccess, three twig variables will be available in all templates: some, nested and cache_ttl.
In addition, extra variables can also be injected in content views. Those can also use the expression language, and use properties from the rendered content:
From within @ezdesign/content/view/full/gallery.html.twig and my_siteaccess, two extra variables will be available: some and provided_variable. The latter is provided by a twig variable provider, a service tagged with ezplatform.view.variable_provider that implements the eZ\Publish\SPI\MVC\View\VariableProvider interface.
So, as you can see, we have made some significant changes to improving the developer side in eZ Platform 3.0 as well as making life easier for editors. More news and updates will be shared through our blog and the eZ forum. If you have any questions please feel free to drop us a comment on discuss.ezplatform.com or reach out to us via email at firstname.lastname@example.org.