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

run() public method

Run REST controller
public run ( ) : mixed
return mixed
    public function run()
    {
        // check implementation
        if (!isset($this->map[$this->method])) {
            throw new NotImplementedException();
        }
        $map = $this->map[$this->method];
        // check permissions
        if (isset($map['acl'])) {
            if (!Acl::isAllowed($this->module, $map['acl'])) {
                throw new ForbiddenException();
            }
        }
        // dispatch controller
        return Application::getInstance()->dispatch($map['module'], $map['controller'], ['crud' => $this->getCrud(), 'primary' => $this->getPrimaryKey(), 'data' => $this->data]);
    }

Usage Example

Example #1
0
 /**
  * Run REST controller
  * @return mixed
  * @throws ForbiddenException
  * @throws NotImplementedException
  */
 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();
 }