protected function run()
    {
        // First convert via subrouting defined routes to a parsable array tree
        $this->setRouteTree(explodeTree($this->getRoutes(), self::ROUTE_SEPARATOR));

        // Retrieve route configuration via match by current request URL ;)
        $routeConfig = $this->getRouteByUrl($this->getStateObject()->getUrl());

        // Real processed request method depends on the override header if set. Otherwise normal request type is used
        $headers = $this->getStateObject()->getHeaders();

        // Override set? and is allowed for the resource? Sometimes clients are not able to e.g. tunnel PUT, DELETE ...
        if (isset($headers['X_HTTP_METHOD_OVERRIDE']) === true && $routeConfig->getOverride() === true) {
            $requestMethod = $headers['X_HTTP_METHOD_OVERRIDE'];

            // Inject into object we use as base -> update :)
            $this->getStateObject()->setMethod($requestMethod);
        } else {
            $requestMethod = $this->getStateObject()->getMethod();
        }

        // Request method should not be processed.
        if ($routeConfig->isAllowed($requestMethod) === false) {
            throw new Doozr_Base_Presenter_Rest_Exception(
                'Method "'.$this->getStateObject()->getMethod().'" not allowed.',
                405
            );
        }

        // Missing argument + message
        if ($this->validateInputArguments(
                $routeConfig->getRequired(),
                $this->getStateObject()->getQueryParams()
            ) !== true
        ) {
            $missingArguments = [];

            foreach ($routeConfig->getRequired() as $key => $value) {
                if (array_key_exists($key, $this->getStateObject()->getQueryParams()->getArray()) === false) {
                    $missingArguments[] = $key.(($value !== null) ? ' => '.$value : '');
                }
            }

            throw new Doozr_Base_Presenter_Rest_Exception(
                'Missing required argument'.((count($missingArguments) > 1) ? 's' : '').': '.
                implode(',', $missingArguments),
                406
            );
        }

        // Try to get data and check if authorization required and failed
        $data = $this->getModel()->getData(
            $this->getStateObject(), $routeConfig
        );

        // Retrieve data from model so that VIEW and MODEL are informed (Observer and this here is the Subject)
        $this->setData(
            $data
        );
    }
protected function run()
    {
        // First convert via subrouting defined routes to a parsable array tree
        $this->setRouteTree(explodeTree($this->getRoutes(), self::ROUTE_SEPARATOR));

        // Retrieve route configuration via match by current request URL ;)
        $routeConfig = $this->getRouteByUrl($this->getStateObject()->getUrl());

        // Real processed request method depends on the override header if set. Otherwise normal request type is used
        $headers = $this->getStateObject()->getHeaders();

        // Override set? and is allowed for the resource? Sometimes clients are not able to e.g. tunnel PUT, DELETE ...
        if (isset($headers['X_HTTP_METHOD_OVERRIDE']) === true && $routeConfig->getOverride() === true) {
            $requestMethod = $headers['X_HTTP_METHOD_OVERRIDE'];

            // Inject into object we use as base -> update :)
            $this->getStateObject()->setMethod($requestMethod);
        } else {
            $requestMethod = $this->getStateObject()->getMethod();
        }

        // Request method should not be processed.
        if ($routeConfig->isAllowed($requestMethod) === false) {
            throw new Doozr_Base_Presenter_Rest_Exception(
                'Method "'.$this->getStateObject()->getMethod().'" not allowed.',
                405
            );
        }

        // Missing argument + message
        if ($this->validateInputArguments(
                $routeConfig->getRequired(),
                $this->getStateObject()->getQueryParams()
            ) !== true
        ) {
            $missingArguments = [];

            foreach ($routeConfig->getRequired() as $key => $value) {
                if (array_key_exists($key, $this->getStateObject()->getQueryParams()->getArray()) === false) {
                    $missingArguments[] = $key.(($value !== null) ? ' => '.$value : '');
                }
            }

            throw new Doozr_Base_Presenter_Rest_Exception(
                'Missing required argument'.((count($missingArguments) > 1) ? 's' : '').': '.
                implode(',', $missingArguments),
                406
            );
        }

        // Try to get data and check if authorization required and failed
        $data = $this->getModel()->getData(
            $this->getStateObject(), $routeConfig
        );

        // Retrieve data from model so that VIEW and MODEL are informed (Observer and this here is the Subject)
        $this->setData(
            $data
        );
    }
protected function run ( ) { // First convert via subrouting defined routes to a parsable array tree $ this -> setRouteTree ( explodeTree ( $ this -> getRoutes ( ) , self :: ROUTE_SEPARATOR ) ) ; // Retrieve route configuration via match by current request URL ;) $ routeConfig = $ this -> getRouteByUrl ( $ this -> getStateObject ( ) -> getUrl ( ) ) ; // Real processed request method depends on the override header if set. Otherwise normal request type is used $ headers = $ this -> getStateObject ( ) -> getHeaders ( ) ; // Override set? and is allowed for the resource? Sometimes clients are not able to e.g. tunnel PUT, DELETE ... if ( isset ( $ headers [ 'X_HTTP_METHOD_OVERRIDE' ] ) === true && $ routeConfig -> getOverride ( ) === true ) { $ requestMethod = $ headers [ 'X_HTTP_METHOD_OVERRIDE' ] ; // Inject into object we use as base -> update :) $ this -> getStateObject ( ) -> setMethod ( $ requestMethod ) ; } else { $ requestMethod = $ this -> getStateObject ( ) -> getMethod ( ) ; } // Request method should not be processed. if ( $ routeConfig -> isAllowed ( $ requestMethod ) === false ) { throw new Doozr_Base_Presenter_Rest_Exception ( 'Method "' . $ this -> getStateObject ( ) -> getMethod ( ) . '" not allowed.' , 405 ) ; } // Missing argument + message if ( $ this -> validateInputArguments ( $ routeConfig -> getRequired ( ) , $ this -> getStateObject ( ) -> getQueryParams ( ) ) !== true ) { $ missingArguments = [ ] ; foreach ( $ routeConfig -> getRequired ( ) as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> getStateObject ( ) -> getQueryParams ( ) -> getArray ( ) ) === false ) { $ missingArguments [ ] = $ key . ( ( $ value !== null ) ? ' => ' . $ value : '' ) ; } } throw new Doozr_Base_Presenter_Rest_Exception ( 'Missing required argument' . ( ( count ( $ missingArguments ) > 1 ) ? 's' : '' ) . ': ' . implode ( ',' , $ missingArguments ) , 406 ) ; } // Try to get data and check if authorization required and failed $ data = $ this -> getModel ( ) -> getData ( $ this -> getStateObject ( ) , $ routeConfig ) ; // Retrieve data from model so that VIEW and MODEL are informed (Observer and this here is the Subject) $ this -> setData ( $ data ) ; }
Executes the configured subroutes if any matches.

@author Benjamin Carl <opensource@clickalicious.de>

@throws Doozr_Base_Presenter_Rest_Exception
Executes the configured subroutes if any matches .