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

With RAD: a settings-only extension

The Settings extension wizard writes settings and event listeners: its topics, the listener class that is safe by default, and moving existing settings with exp:ini move-all instead.

Download as PDF

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

On this page

With RAD: a settings-only extension

Tutorial 7. The Settings extension wizard (/setup/settingsextension) writes extensions that are mostly settings: image aliases, event listeners, view cache rules, information collection, trigger operations, siteaccess settings, extension roots, icon themes and more. The output below was produced by the wizard's generator (expSettingsExtensionWizard::files()) with two event listeners chosen; every PHP file passed php -l.

The topics

Each topic writes one settings file (the wizard names it):

TopicWrites toIs for
Image aliasesimage.ini"A named size, with the filters that produce it."
Event listenerssite.ini"A callback on something the kernel announces."
View cache clearing rulesviewcache.ini"What else has to be rebuilt when one object is published."
Information collectioncollect.ini"What happens when a visitor fills in a form built out of content."
Trigger operationsworkflow.ini"Which operations a workflow may be bound to."
Siteaccess settingssite.ini"Settings that apply to one siteaccess only, kept with the extension."
Additional extension rootssite.ini"Somewhere other than extension/ for extensions to live."
Icon themeicon.ini"A set of icons an extension brings with it."

Plus the listener class, API examples, README, metadata, Composer file, .gitignore and license.

Event listeners

With the events content/state/assign and response/output and the class mysiteSettingsListeners, the wizard wrote:

.gitignore
LICENSE
README.md
classes/mysitesettingslisteners.php
composer.json
doc/examples.php
extension.xml
ezinfo.php
settings/site.ini.append.php
[Event]
Listeners[]=content/state/assign@mysiteSettingsListeners::contentStateAssign
Listeners[]=response/output@mysiteSettingsListeners::responseOutput

The listener class knows which kind each event is and is safe until you write it:

/**
 * response/output
 *
 * The whole page, about to be sent. Whatever is returned is what the
 * browser gets.
 *
 * A filter event. Whatever this returns is what the rest of the
 * system uses, so returning nothing destroys the value. The first
 * argument is the value; anything after it is context.
 */
public static function responseOutput( $value = null )
{
    // Not written yet. Handing the value back unchanged leaves the
    // system working exactly as it did before this listener existed.
    return $value;
}

The notify listener (contentStateAssign()) returns nothing, with the note "What this returns is ignored, and nothing waits for it either - anything slow here is felt by whoever caused it." Fill them in as in Events, listeners and filters. Note that content/state/assign is notified with ( $objectID, $selectedStateIDList ); give your method both parameters.

Moving existing settings instead

When the settings already exist in settings/siteaccess/<sa>/ or settings/override/, the settings command builds the extension from them, keeping every value in effect:

./console exp:ini move-all siteaccess:mysite extension:mysite_settings:siteaccess:mysite --create-extension --dry-run

See Settings that live in an extension.

Switch it on

./console exp:ini add 'site.ini/ExtensionSettings/ActiveExtensions[]' mysite_settings global
php bin/php/ezpgenerateautoloads.php -e
php bin/php/ezcache.php --clear-tag=ini

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