izzum\statemachine\StateMachine::callEventHandler PHP Method

callEventHandler() protected method

Try to call a method on the contextual entity / domain model ONLY IF the method exists.Any arguments passed to this method will be passed on to the method called on the entity.
protected callEventHandler ( mixed $object, string $method ) : boolean | mixed
$object mixed the object on which we want to call the method
$method string the method to call on the object
return boolean | mixed
    protected function callEventHandler($object, $method)
    {
        // return true by default (because of transition guard callbacks that
        // might not exist)
        $output = true;
        // check if method exists.
        if (method_exists($object, $method)) {
            // && $object !== $this) { //prevent recursion
            $args = func_get_args();
            // remove $object and $method from $args so we only have the other arguments
            array_shift($args);
            array_shift($args);
            // have the methods be able to return what they like
            // but make sure the 'onCheckCanTransition method returns a boolean
            $output = call_user_func_array(array($object, $method), $args);
        }
        return $output;
    }