Exemplo n.º 1
0
 public function getAll($startIndex = 0, $search = null)
 {
     $condition = new Condition();
     $condition->in('status', [Table\App::STATUS_ACTIVE, Table\App::STATUS_PENDING]);
     if (!empty($search)) {
         $condition->like('name', '%' . $search . '%');
     }
     return new ResultSet($this->appTable->getCount($condition), $startIndex, 16, $this->appTable->getAll($startIndex, 16, 'id', Sql::SORT_DESC, $condition, Fields::blacklist(['url', 'parameters', 'appSecret'])));
 }
Exemplo n.º 2
0
 public function create($userId, $name, $url, array $scopes = null)
 {
     // validate data
     $this->assertName($name);
     $this->assertUrl($url);
     // check limit of apps which an user can create
     $condition = new Condition();
     $condition->equals('userId', $userId);
     $condition->in('status', [Table\App::STATUS_ACTIVE, Table\App::STATUS_PENDING, Table\App::STATUS_DEACTIVATED]);
     if ($this->appTable->getCount($condition) > $this->appCount) {
         throw new StatusCode\BadRequestException('Maximal amount of apps reached. Please delete another app in order to register a new one');
     }
     $scopes = $this->getValidUserScopes($userId, $scopes);
     if (empty($scopes)) {
         throw new StatusCode\BadRequestException('Provide at least one valid scope for the app');
     }
     $this->appService->create($userId, $this->appApproval === false ? Table\App::STATUS_ACTIVE : Table\App::STATUS_PENDING, $name, $url, null, $scopes);
 }