/** * Handle attach permission to role * * @param AttachPermissionToRole $command * @return void */ public function handle(AttachPermissionToRole $command) { $id = $command->id; $permissionId = $command->permissionId; $role = $this->retrieveRole($id); $permission = $this->retrievePermission($permissionId); $role->attachPermission($permission); $this->roleRepository->save($role); $this->events->fire($role->releaseEvents()); }
/** * 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)]); }
/** * Handle describe role * * @param DescribeRole $command * @return void */ public function handle(DescribeRole $command) { $name = new FoundationDomainModels\Name($command->name); $description = new FoundationDomainModels\Description($command->description); $id = new AccountDomainModels\RoleId($command->id); $this->ensureNameIsUnique($name, $id); $role = $this->retrieveRole($id->value()); $role->setName($name); $role->describe($description); $this->roleRepository->save($role); $this->events->fire($role->releaseEvents()); }