public function startup() { try { $id = $this->getParameter('id'); if ($id !== NULL && ($id = $this->isValidId($id)) === FALSE) { throw BadRequestException::methodNotSupported('Url must follow convention /presenter/id/relation/relationId.' . ' Valid ID is only positive, non zero integer.'); } $action = $this->getAction(); if ($action === 'create' && $id) { $this->changeAction('update'); } parent::startup(); if (strpos($action, 'read') === FALSE) { $this->inputData = $this->inputData ?: $this->getInputData(); } if (($relation = $this->getParameter('relation')) !== NULL) { $this->table = $this->db->table($relation)->where($this->getTableName(), $id); $this->deepListing = $this->queryFilter = NULL; } else { $this->table = $this->db->table($this->getTableName()); } } catch (BadRequestException $ex) { $this->sendErrorResource($ex); } }
public function startup() { if ($this->getAction() !== 'read') { throw BadRequestException::forbidden('Stat presenter handles GET requests ONLY.'); } ResourcePresenter::startup(); $this->series = $this->getParameter('series'); $this->data = $this->getParameter('data'); $this->dateBegin = $this->getParameter('dateBegin'); $this->dateEnd = $this->getParameter('dateEnd'); }
/** * On presenter startup */ protected function startup() { parent::startup(); $this->authentication->setAuthProcess($this->basicAuthentication); }
/** * On presenter startup */ protected function startup() { parent::startup(); $this->client = $this->clientStorage->getClient($this->getParameter(GrantType::CLIENT_ID_KEY), $this->getParameter(GrantType::CLIENT_SECRET_KEY)); }
/** * @throws AuthenticationException * @throws \Drahak\Restful\Application\BadRequestException * @throws \Exception */ public function startup() { //kontrola přihlášeného uživatele $apiKey = @$this->getInput()->getData()['apiKey']; if (empty($apiKey)) { $authorizationHeader = $this->getHttpRequest()->getHeader('Authorization'); $apiKey = substr($authorizationHeader, 0, 7) == "ApiKey " ? substr($authorizationHeader, 7) : null; } if (empty($apiKey)) { throw new AuthenticationException("You have to use API KEY!", IAuthenticator::FAILURE); } else { $this->identity = $this->usersFacade->authenticateUserByApiKey($apiKey, $this->currentUser); } //spuštění výchozí startup() akce parent::startup(); }