public function chooseAction(HttpRequest $request) { $action = Primitive::choice('action')->setList($this->methodMap); if ($this->getDefaultAction()) { $action->setDefault($this->getDefaultAction()); } Form::create()->add($action)->import($request->getGet())->importMore($request->getPost())->importMore($request->getAttached()); if (!($command = $action->getValue())) { return $action->getDefault(); } return $command; }
private function getPostFields(HttpRequest $request) { if ($request->hasBody()) { return $request->getBody(); } else { if ($this->oldUrlConstructor) { return UrlParamsUtils::toStringOneDeepLvl($request->getPost()); } else { $fileList = array_map([$this, 'fileFilter'], UrlParamsUtils::toParamsList($request->getFiles())); if (empty($fileList)) { return UrlParamsUtils::toString($request->getPost()); } else { $postList = UrlParamsUtils::toParamsList($request->getPost()); if (!is_null($atParam = $this->findAtParamInPost($postList))) { throw new NetworkException('Security excepion: not allowed send post param ' . $atParam . ' which begins from @ in request which contains files'); } return array_merge($postList, $fileList); } } } }