The building blocks of an extension
The book's fifth chapter goes through the kinds of extension one by one. This page keeps its order, says what each piece
is, and sends you to the page that covers it now. The code in the book is PHP 4 style (& references, include_once, EZ_
constants). Exponential's PHP is 8: classes are autoloaded, constants belong to classes, and no references are needed.
Modules
A module is a set of views reached by an address: /hello/world is the view world of the module hello. A module
lives in modules/<name>/ of an extension.
- Module definition (
module.php): the module's name, its$ViewList(each view with itsscript, theparamsit takes,unordered_params,functions,default_navigation_part, andsingle_post_actionsorpost_actions) and its$FunctionListfor permissions (Modules and views, Policy functions and access). - View parameters: the parts of the address after the view name, in the order
paramsnames them (View parameters). - View actions and post variables: a form button's name maps to an action, and
isCurrentAction()tells the view script what was pressed. Forms must carry the form token. - View navigation:
default_navigation_partchooses which tab of the administration is active. - Module coding: a view script reads its input (
$Params,$_POSTthrough the module'shttpobject) and ends by filling$Result:content(the output of a template),path(the breadcrumb), and optionallyleft_menu,title_path,pagelayout(View results and the pagelayout). Redirect with$Module->redirectTo( ... ), and return errors with$Module->handleError( eZError::KERNEL_NOT_FOUND, 'kernel' ).
Datatypes
A datatype is a class that knows how to validate, store, display and edit one kind of value, with templates for each of
those. The book's chapter on datatypes builds one by overriding the methods of eZDataType. Same pattern now:
Datatypes and
Datatype storage, validation and templates.
Template operators and functions
An operator ({$x|myoperator}) is a class registered by a template autoload file. For simple cases, a PHP function in
template.ini is enough (caching in templates, last section). Real ones:
Template operators,
Template functions.
Workflow events and triggers
A new event type is a class in eventtypes/event/<type>/ that decides, when it runs, whether the workflow goes on
(STATUS_ACCEPTED), waits (STATUS_FETCH_TEMPLATE_REPEAT, STATUS_DEFERRED_TO_CRON_REPEAT) or stops (STATUS_REJECTED)
(workflow event types,
Triggers and workflows for developers).
The user side is in workflows and triggers.
Notifications
A notification handler turns the events the system collects into mails. The statuses the book lists
(EZ_NOTIFICATIONEVENTHANDLER_EVENT_HANDLED, _SKIPPED, _UNKNOWN, _ERROR) are the class constants EVENT_HANDLED, EVENT_SKIPPED and so on of
eZNotificationEventHandler today. See Notifications for developers.
Moving data in and out: SOAP and RSS
The book finishes with web services: SOAP for programs, RSS for feeds. Feeds are still RSS and Atom, from the administration (RSS feeds). For programs the interface is the REST API, with keys and OAuth (REST API, API keys); build against it rather than adding SOAP.
Next: extension development practices.
Source and license
Adapted from chapter 5, "Extending eZ publish", of Learning eZ publish: Building Content Management Solutions by Paul Borgermans, Tony Wood, Paul Forsyth, Martin Bauer, Björn Dieding and Ben Pirt (additional material by Bruce Morrison), second edition, 2024, Book-Learning-eZPublish. Copyright (c) 2004-2024 7x and Graham Brookins. Licensed under the GNU Free Documentation License, version 1.3 or any later version, with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts (the license). Changes: rearranged as a map to the current developer pages; folder names, settings and constants checked against Exponential 6; SOAP replaced by the REST API.