Bluz\Controller\Mapper\Rest::run PHP Method

run() public method

Run REST controller
public run ( ) : mixed
return mixed
    public function run()
    {
        $params = $this->params;
        if (sizeof($params)) {
            $this->primary = explode('-', array_shift($params));
        }
        if (sizeof($params)) {
            $this->relation = array_shift($params);
        }
        if (sizeof($params)) {
            $this->relationId = array_shift($params);
        }
        // OPTIONS
        if ('OPTIONS' == $this->method) {
            $this->data = array_keys($this->map);
        }
        // dispatch controller
        return parent::run();
    }

Usage Example

Example #1
0
<?php

/**
 * Public REST for pages
 *
 * @author   Anton Shevchuk
 * @created  30.10.12 09:29
 */
namespace Application;

use Application\Pages;
use Bluz\Controller\Controller;
use Bluz\Controller\Mapper\Rest;
/**
 * @accept JSON
 * @accept HTML
 *
 * @return mixed
 */
return function () {
    /**
     * @var Controller $this
     */
    $rest = new Rest();
    $rest->setCrud(Pages\Crud::getInstance());
    $rest->head('system', 'rest/head');
    $rest->get('system', 'rest/get');
    return $rest->run();
};
Rest