7.22. Opt_Component_Interface
7.22.6. processEvent()
7.22.5. manageAttributes()
« Previous
7.22.7. set()
Next »

7.22.6. processEvent()

ConstructAbstract method
Visibilitypublic
Referenceboolean processEvent($event)
Argument list
$event - $string
The event name
Returned valueThe boolean value indicating if the specified event occured or not.

processEvent() is called to ask the component if the specified $event is going to happen. The method must return true in order to display the content associated to the specified event, or false otherwise. Optionally, it can do some extra stuff. In the example below, we are handling the error event. If it happens, the component creates an extra template variable with the error message:

public function processEvent($event) 
{
    if($event == 'error')
    {
        if(!$this->valid)
        {
            // An error occurred
            $this->view->errorMessage = $this->errorMessage;
            return true;
        }
    }
    return false;
} // end processEvent();

Now we can use it in the template:

<opt:component from="$component">
    ...
    <opt:onEvent name="error">
        <p>An error occurred: {$errorMessage}</p>
    </opt:onEvent>
</opt:component>

For the unsupported events, processEvent() should return false.

7.22.6. processEvent()
7.22. Opt_Component_Interface
« Previous
7.22.5. manageAttributes()
Next »
7.22.7. set()