EXC | DEV | Documentation
The class \exc\controller
provides the controller behavior. Every controller must inherit from this class or one of its sub classes.
Registers a callback to given message.
$controller->on(string $messageName, callable $callback, mixed $cookie)
$messageName (string)(required) The name of the message to add the callback to.
$callback (callable)(required) The function to be executed when the message is published.
$cookie (mixed)(optional) An additional parameter that will be passed to the callback function when executed.
Publishes a message with the passed parameters.
$controller->publish(string $messageName, array $params)
$messageName (string)(required) The name of the message to publish.
$params (array)(optional) An array with the parameters used to call the functions registered to this message.
Remove a callback registered to given message.
$controller->off(string $messageName, callable $callback)
$messageName (string)(required) The name of the message with the passed callback.
$callback (callable)(required) The function to be removed.
Returns true if the passed object is an instance of a controller.
$bool = \exc\controller::isControllerInstance(object $any)
$any (object)(required) The object to test.