public function update($userId, $appId, $name, $url, array $scopes = null) { $app = $this->appTable->get($appId); if (!empty($app)) { if ($app['userId'] != $userId) { throw new StatusCode\BadRequestException('App does not belong to the user'); } // validate data $this->assertName($name); $this->assertUrl($url); $scopes = $this->getValidUserScopes($userId, $scopes); if (empty($scopes)) { throw new StatusCode\BadRequestException('Provide at least one valid scope for the app'); } $this->appService->update($appId, $app['status'], $name, $url, null, $scopes); } else { throw new StatusCode\NotFoundException('Could not find app'); } }
/** * Returns the PUT response * * @param \PSX\Record\RecordInterface $record * @return array|\PSX\Record\RecordInterface */ protected function doPut($record) { $this->appService->update((int) $this->getUriFragment('app_id'), $record->status, $record->name, $record->url, $record->parameters, $record->scopes); return array('success' => true, 'message' => 'App successful updated'); }