예제 #1
0
 /**
  * Retrieve role and ensure role is exist
  * 
  * @param  mixed $id
  * @return AccountDomainModels\Role
  */
 protected function retrieveRole($id)
 {
     $role = $this->roleRepository->findById($id);
     if (is_null($role)) {
         throw new ValueNotFoundException("[{$id}] is not valid role id");
     }
     return $role;
 }
예제 #2
0
 /**
  * Build roles from id of roles
  * 
  * @param  array $idOfRoles
  * @return array
  */
 protected function buildRoles($idOfRoles)
 {
     $roles = [];
     foreach ($idOfRoles as $id) {
         $roles[] = $this->roleRepository->findById($id);
     }
     return $roles;
 }
예제 #3
0
파일: Init.php 프로젝트: inoplate/account
 /**
  * Handle incoming console command
  * 
  * @return void
  */
 public function handle()
 {
     $this->truncateTable();
     $this->initRole();
     $administrator = $this->roleRepository->findByName('Administrator');
     $this->attachPermissionToRole($administrator);
     $this->initUser($administrator);
 }
예제 #4
0
 /**
  * Determine if specification was satisfied by given candidate
  * 
  * @param  SpecificationCandidate $candidate
  * @return boolean
  */
 public function isSatisfiedBy(SpecificationCandidate $candidate)
 {
     if ($user = $this->roleRepository->findByName($candidate->value())) {
         if (!$user->id()->equal($this->id)) {
             return false;
         }
     }
     return true;
 }
예제 #5
0
 /**
  * Handle role creation
  * 
  * @param  CreateNewRole $command
  * @return void
  */
 public function handle(CreateNewRole $command)
 {
     $name = new FoundationDomainModels\Name($command->name);
     $description = new FoundationDomainModels\Description($command->description);
     $id = $this->roleRepository->nextIdentity();
     $this->ensureNameIsUnique($name);
     $role = new AccountDomainModels\Role($id, $name, $description);
     $this->roleRepository->save($role);
     $this->events->fire([new RoleWasCreated($role)]);
 }
예제 #6
0
 /**
  * Handle incoming console command
  * 
  * @return void
  */
 public function handle()
 {
     $roleName = $this->ask('Role name?');
     $role = $this->roleRepository->findByName($roleName);
     if (is_null($role)) {
         $this->error('Rolename [' . $roleName . '] doesn\'t exist ');
     }
     $this->info('Clear attached permissions');
     $this->resetTable($role);
 }
예제 #7
0
 public function getUpdate(RoleRepository $roleRepository, $id)
 {
     $user = $this->userRepository->findById($id);
     $roles = $roleRepository->all();
     if (is_null($user)) {
         abort(404);
     } else {
         $user = $user->toArray();
     }
     return $this->getResponse('inoplate-account::users.update', compact('user', 'roles'));
 }