Ip\Internal\Grid\Model\Table::handleMethod PHP Метод

handleMethod() публичный Метод

public handleMethod ( )
    public function handleMethod()
    {
        $request = $this->request->getRequest();
        if (empty($request['method'])) {
            throw new \Ip\Exception('Missing request data');
        }
        $method = $request['method'];
        if (in_array($method, array('update', 'create', 'delete', 'move'))) {
            $this->request->mustBePost();
        }
        if (in_array($method, array('update', 'create'))) {
            $data = $this->request->getPost();
            $params = $data;
        } elseif (in_array($method, array('search'))) {
            $data = $this->request->getQuery();
            $params = $data;
        } else {
            $data = $this->request->getRequest();
            $params = empty($data['params']) ? array() : $data['params'];
        }
        if ($this->subgridConfig->preventAction()) {
            $preventReason = call_user_func($this->subgridConfig->preventAction(), $method, $params, $this->statusVariables);
            if ($preventReason) {
                if (is_array($preventReason)) {
                    return $preventReason;
                } else {
                    return array(Commands::showMessage($preventReason));
                }
            }
        }
        unset($params['method']);
        unset($params['aa']);
        switch ($method) {
            case 'init':
                return $this->init();
                break;
            case 'page':
                return $this->page($params);
                break;
            case 'setPageSize':
                return $this->setPageSize($params);
                break;
            case 'setLanguage':
                return $this->setLanguage($params);
                break;
            case 'delete':
                return $this->delete($params);
                break;
            case 'updateForm':
                $updateForm = $this->updateForm($params);
                $view = ipView('../view/updateForm.php', array('updateForm' => $updateForm))->render();
                return $view;
                break;
            case 'update':
                return $this->update($params);
                break;
            case 'move':
                return $this->move($params);
                break;
            case 'movePosition':
                return $this->movePosition($params);
                break;
            case 'create':
                return $this->create($params);
                break;
            case 'search':
                return $this->search($params);
                break;
            case 'subgrid':
                return $this->subgrid($params);
                break;
            case 'order':
                return $this->order($params);
                break;
        }
        return null;
    }