phpBB

Development Wiki

Category:Events and Listeners

From phpBB Development Wiki

Revision as of 21:34, 28 September 2015 by 3di (Talk | contribs)

Events

What are events?

Events are triggered in various places of the core phpBB code. Listeners in extensions can be subscribed to these events. They are able to execute code whenever the respective event has occured. For more information, see the wiki article for listeners.

Former names for events are "hook location" and "ledge".

Why do we need events?

Events allow extensions to execute code in many locations within core phpBB code, without modifying any of the code. That way extensions can add features, remove functionality or modify behaviour easily and while maintaining easy compatibility and simple update procedures.

Listeners

What are listeners?

Listeners are a way of injecting or modifying code without having to edit the file. They are injected into points that we call Events.

Listeners might also be known as hooks.

Why are listeners helpful?

MOD installation in phpBB 3.0 (Olympus) was difficult because it required code modification to the core phpBB files. Such edits either had to be done manually or a separate tool had to be installed to perform automatic changes. Because core files were changed from their original state, administrators often had trouble updating their phpBB version or installing more MODs because the code that was being looked for during the update or MOD installation was no longer present in its original state.

One of the aims of phpBB 3.1 (Ascraeus) is to make the extension of default functionality much easier without causing problems in the future with updating. Instead of MODs, our customisations community is encouraged to create Extensions and to hook their functionality into the core by the use of Event Listeners.

How do I use a listener?

Create a file in your extension which uses the identifier to hook into the code and inject the code you need into the core or modify the data you need. For more information see the Add_Listeners page.

Terminology

Name Explanation
Events Events are triggered in various places of the core phpBB code. Listeners in extensions subscribe to these events. They are able to execute code whenever the respective event has occured. For more information, see the wiki article for listeners.
Listeners Listeners are triggered by events. They can process incoming data and manipulate variables in the scope of the event. So they can change phpBB's behaviour, add new functionality or if used in the context of templates, modify the output. An alternative name for listeners are "hooks".
Subscriber A subscriber registers listeners on the dispatcher.
Dispatcher The event dispatcher calls the listeners for a certain event when that event is triggered.

Further Reading

Pages in category "Events and Listeners"

The following 5 pages are in this category, out of 5 total.