Пример #1
0
 /**
  * Get buckets this user has access to
  */
 public function getBuckets()
 {
     $buckets = Bucket::find(array('$or' => array(array('roles.' . $this->id => array('$exists' => 1)), array('roles.all' => array('$exists' => 1)))));
     \Utils::model_sort($buckets, 'description');
     return $buckets;
 }
Пример #2
0
 /**
  * Gets a single software bucket
  * If no key is set, an empty Bucket object will be returned which will act as a repository
  *
  * @param string $key optional
  *
  * @return Bucket
  */
 public function bucket($key = null)
 {
     if (!$this->id) {
         throw new Exception("The server has no ID, can\\'t get buckets");
     }
     $bucket = new Bucket($this->patrol);
     $bucket->defaults(['server_id' => $this->id]);
     if (is_null($key)) {
         return $bucket;
     }
     try {
         return $bucket->find($key);
     } catch (Exception $ex) {
         if ($ex->getMessage() === "Bucket does not exist") {
             $bucket->key = $key;
             return $bucket;
         }
     }
     return null;
 }