src/Loops/Element.php
public function action($parameter) {
        $result = FALSE;

        if($parameter) {
            $name = $parameter[0];

            $method_name = $name."Action";

            if(method_exists($this, $method_name)) {
                $result = $this->$method_name(array_slice($parameter, 1));
            }

            if(in_array($result, [FALSE, NULL], TRUE)) {
                if($parameter && $this->offsetExists($name)) {
                    $child = $this->offsetGet($name);
                    if($child instanceof ElementInterface) {
                        $result = $child->action(array_slice($parameter, 1));
                    }
                }
            }
        }

        if(in_array($result, [FALSE, NULL], TRUE)) {
            if($this->delegate_action) {
                if($this->offsetExists($this->delegate_action)) {
                    $child = $this->offsetGet($this->delegate_action);
                    if($child instanceof ElementInterface) {
                        $result = $child->action($parameter);
                    }
                }
            }
        }

        if(in_array($result, [FALSE, NULL], TRUE)) {
            if(!$parameter) {
                if($this->direct_access) {
                    $result = TRUE;
                }
                else {
                    $loops = $this->getLoops();

                    if($loops->hasService("request") && $loops->getService("request")->isAjax() && $this->ajax_access) {
                        $result = TRUE;
                    }
                }
            }
        }

        if($result === TRUE) {
            $result = $this;
        }

        return $result;
    }
public function action($parameter) {
        $result = FALSE;

        if($parameter) {
            $name = $parameter[0];

            $method_name = $name."Action";

            if(method_exists($this, $method_name)) {
                $result = $this->$method_name(array_slice($parameter, 1));
            }

            if(in_array($result, [FALSE, NULL], TRUE)) {
                if($parameter && $this->offsetExists($name)) {
                    $child = $this->offsetGet($name);
                    if($child instanceof ElementInterface) {
                        $result = $child->action(array_slice($parameter, 1));
                    }
                }
            }
        }

        if(in_array($result, [FALSE, NULL], TRUE)) {
            if($this->delegate_action) {
                if($this->offsetExists($this->delegate_action)) {
                    $child = $this->offsetGet($this->delegate_action);
                    if($child instanceof ElementInterface) {
                        $result = $child->action($parameter);
                    }
                }
            }
        }

        if(in_array($result, [FALSE, NULL], TRUE)) {
            if(!$parameter) {
                if($this->direct_access) {
                    $result = TRUE;
                }
                else {
                    $loops = $this->getLoops();

                    if($loops->hasService("request") && $loops->getService("request")->isAjax() && $this->ajax_access) {
                        $result = TRUE;
                    }
                }
            }
        }

        if($result === TRUE) {
            $result = $this;
        }

        return $result;
    }
public function action ( $ parameter ) { $ result = FALSE ; if ( $ parameter ) { $ name = $ parameter [ 0 ] ; $ method_name = $ name . "Action" ; if ( method_exists ( $ this , $ method_name ) ) { $ result = $ this -> $ method_name ( array_slice ( $ parameter , 1 ) ) ; } if ( in_array ( $ result , [ FALSE , NULL ] , TRUE ) ) { if ( $ parameter && $ this -> offsetExists ( $ name ) ) { $ child = $ this -> offsetGet ( $ name ) ; if ( $ child instanceof ElementInterface ) { $ result = $ child -> action ( array_slice ( $ parameter , 1 ) ) ; } } } } if ( in_array ( $ result , [ FALSE , NULL ] , TRUE ) ) { if ( $ this -> delegate_action ) { if ( $ this -> offsetExists ( $ this -> delegate_action ) ) { $ child = $ this -> offsetGet ( $ this -> delegate_action ) ; if ( $ child instanceof ElementInterface ) { $ result = $ child -> action ( $ parameter ) ; } } } } if ( in_array ( $ result , [ FALSE , NULL ] , TRUE ) ) { if ( ! $ parameter ) { if ( $ this -> direct_access ) { $ result = TRUE ; } else { $ loops = $ this -> getLoops ( ) ; if ( $ loops -> hasService ( "request" ) && $ loops -> getService ( "request" ) -> isAjax ( ) && $ this -> ajax_access ) { $ result = TRUE ; } } } } if ( $ result === TRUE ) { $ result = $ this ; } return $ result ; }
Default action processing

The default behaviour of an element is to not accept a request.
An element only accepts requests on default, when no parameter were passed and direct_access has been set to TRUE.
In an ajax call, it is also possible to set ajax_access to TRUE for accepting the request. The service request will
be checked if this currently is an ajax call.
The action method will return itself (rather than TRUE) when accepting a request. This makes it possible to determine
which (sub) element actually accepted the request.

If parameters are given, the following logic can be used to determine if a request should be accepted:
1. Take the first parameter and check for a method named "{param}Action", pass all parameters to it and use the resulting value.
If such a method does not exist or the value is NULL or FALSE do not accept the request, continue.
2. Take the first parameter and check if there is another Loops\Element instance at the offset defined by the parameter (->offsetExists($param) & ->offsetGet($param))
If such object exists execute that objects action, pass the rest of the parameter and use its return value, continue if it was NULL or FALSE.
3. Check if the element defines a property delegate_action and, prepend it to the action parameters and apply step 2.

@param array $parameter The action parameter.
@return mixed The processed value
Default action processing