Esempio n. 1
0
 /**
  * Deletes the roles with given uniqueness.
  *
  * @param string $id
  *
  * @throws NonExistentProfileException
  */
 public function delete($id)
 {
     $result = $this->connectToStorage->connect()->deleteOne(['_id' => $id]);
     if ($result->getDeletedCount() === 0) {
         throw new NonExistentProfileException();
     }
 }
Esempio n. 2
0
 /**
  * Picks the role with given code.
  *
  * @param string $code
  *
  * @throws NonExistentCodeException
  *
  * @return Role
  */
 public function pick($code)
 {
     $role = $this->connectToStorage->connect()->findOne(['code' => $code]);
     if (!$role) {
         throw new NonExistentCodeException($code);
     }
     return $role;
 }
Esempio n. 3
0
 /**
  * Creates a role.
  *
  * @param string|null $id
  * @param string      $code
  * @param string      $title
  *
  * @return string
  */
 public function create($id, $code, $title)
 {
     $id = $id ?: uniqid();
     $this->connectToStorage->connect()->insertOne(new Role($id, $code, $title));
     return $id;
 }
 /**
  * Collects roles.
  *
  * @return Roles
  */
 public function collect()
 {
     $roles = new Roles($this->connectToStorage->connect()->find());
     return $roles;
 }