SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 189 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


If we do not follow the naming convention, we can register a class in the
same way as we register a function, as described earlier in the chapter.
When plugins are imported into Joomla! the global event dispatcher will
automatically look for listener classes and register them.
You probably also noticed the names of the two methods are identical to the names
of the events they handle. This is essential when creating JPlugin subclasses. As we
do not manually register each event to each method, this is the only way in which
the event dispatcher can determine which event a method is designed to handle.
The onAfterDisplayFoobar() method has one major difference to the other
method; it returns a value. You may remember that earlier we mentioned that when
an event is triggered we get an array of all the results.
Chapter 6
[ 141 ]
This is an example of how we might choose to handle the results of the
onAfterDisplayFoobar event:
$arguments = array(&$foobar);
$result = $mainframe->triggerEvent('onAfterDisplayFoobar',
$arguments);
$foobar->onAfterDisplayFoobar = trim(implode("\n", $result));
What we are doing is taking all the string values returned by the
onAfterDisplayFoobar event handlers and imploding them into one string.


Pages:
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201