Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,075 of 9,075 pages
About the help in other languages
All help pages

With RAD: handlers and kernel overrides

The Handler wizard writes a mail transport chosen by a setting; the Kernel override wizard writes a copy with its provenance and a drift check. Both from real output.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-3-extension-developer/tutorials/rad-handlers-and-kernel-overrides.md

On this page

With RAD: handlers and kernel overrides

Tutorial 8. Two wizards change system behavior beyond your own code: the Handler extension wizard (/setup/handlerextension/<kind>) writes a class the system uses in place of its default, chosen by one setting, and the Kernel override wizard (/setup/kerneloverride) writes the last resort, a replacement of a kernel class. The output below was produced by the wizards' generators (expHandlerWizard::files(), expKernelOverrideWizard::files()); every PHP file passed php -l.

Part A: a mail transport

1. The form

Open /setup/handlerextension/mail. The page explains the kind from the wizard's recipe: "How mail leaves the system. The default hands mail to php, which hands it to the machine. A transport of your own can send it through an api, queue it, or write it to disk on a machine that must not send anything." It names the base class (eZMailTransport, lib/ezutils/classes/ezmailtransport.php) and the setting (site.ini [MailSettings] TransportAlias).

FieldValue
Extension namemysite_mail
Aliasmysitelog
Class namemysiteLogMailTransport
TitleLog mail transport

2. The files

.gitignore
LICENSE
README.md
classes/mysitelogmailtransport.php
composer.json
doc/examples.php
extension.xml
ezinfo.php
settings/site.ini.append.php
[MailSettings]
TransportAlias[mysitelog]=mysiteLogMailTransport
class mysiteLogMailTransport extends eZMailTransport
{
    /**
     * Sends one mail and says whether it went. Returning false is how a
     * failure is reported; nothing else is read.
     */
    public function sendMail( eZMail $mail )
    {
        // Not written yet. Returning true keeps the system
        // working the way it did before this handler was switched on.
        return true;
    }
}

3. Write it, then select it

Replace the body with the logging transport of Handlers named by settings. The wizard's recipe note matters: "Set Transport in the same section to the alias, or the default is still used." Set it on the development server only:

./console exp:ini set site.ini/MailSettings/Transport mysitelog global

Warning

As generated, sendMail() returns true without sending anything. Once Transport names the alias, every mail is silently dropped until you write the method. Write it before you select it.

Part B: a kernel override

1. The form

Open /setup/kerneloverride. Name the kernel class to replace and, required, the reason: why nothing lighter works. The wizard refuses a class that something already overrides ("Two overrides of one class do not combine").

2. The files

For eZSection:

.gitignore
LICENSE
README.md
bin/checkdrift.php
composer.json
extension.xml
ezinfo.php
kernel_override/ezsection.php

The copy starts with a header that records its provenance:

 * ##  KERNEL OVERRIDE - this file replaces a kernel class                  ##
 *
 * eZSection, copied from
 *
 *     kernel/classes/ezsection.php
 *     md5 <checksum of the kernel file when copied>
 *     copied <date>

followed by the reason and "What you have taken on": "This is not a subclass. There is no parent to call and nothing is inherited". bin/checkdrift.php compares the kernel file with that checksum after every upgrade.

3. Switching it on

The generated README lists the steps: activate the extension; allow overrides in config.php with define( 'EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE', true );; generate the override map with php bin/php/ezpgenerateautoloads.php -o; clear the caches. Then run the drift check in every deployment.

Read Kernel class overrides: the last resort before you use this.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x