Event handlers are the functions that concrete5 executes when events are fired. In the previous recipe, we used the custom class MyClass
and its function onStartFired
as the event handler. concrete5 allows developers to actually pass parameters to these handlers as well. In this recipe, we build upon the event handler from the previous recipe and pass a message to the
onStartFired
handler, which will output that message.
We will be using the code that we created in the previous recipe as the base for this one. Also, make sure that you have enabled events as described in the first recipe in this chapter.
The steps for passing parameters to event handlers are as follows:
Open the
site_events.php
file located in/config
in your code editor.Add a new argument to the event registration code, so it looks like the following code:
Events::extend('on_start', 'MyClass', 'onStartFired', 'libraries/my_class.php', array('This is a custom message...