/** * @test */ public function setRolesWorks() { $roles = array($this->administratorRole, $this->customerRole); $expectedRoles = array($this->administratorRole->getIdentifier() => $this->administratorRole, $this->customerRole->getIdentifier() => $this->customerRole); $this->account->setRoles($roles); $this->assertSame($expectedRoles, $this->account->getRoles()); }
/** * @return \Ag\Login\Domain\Model\AccountDescriptor */ public function getDescriptor() { $d = new AccountDescriptor(); $d->accountId = $this->accountId; $d->email = $this->login->getAccountIdentifier(); $d->name = $this->name; $d->imageId = $this->imageId; $d->roles = $this->login->getRoles(); foreach ($d->roles as $key => $role) { $d->roles[$key] = $this->flowRoleToRole($role); } return $d; }
/** * Overrides any assigned roles of the given account and potentially carries out further actions which are needed * to properly reflect these changes. * * @param Account $account The account to assign the roles to * @param array $newRoleIdentifiers A list of fully qualified role identifiers, or role identifiers relative to the TYPO3.Neos namespace * @return void * @api */ public function setRolesForAccount(Account $account, array $newRoleIdentifiers) { $currentRoles = $account->getRoles(); foreach ($currentRoles as $roleIdentifier => $role) { $roleIdentifier = $this->normalizeRoleIdentifier($roleIdentifier); if (!in_array($roleIdentifier, $newRoleIdentifiers)) { $this->removeRoleFromAccount($account, $roleIdentifier); } } foreach ($newRoleIdentifiers as $roleIdentifier) { if (!in_array($roleIdentifier, array_keys($currentRoles))) { $this->addRoleToAccount($account, $roleIdentifier); } } }
/** * {@inheritDoc} */ public function getRoles() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getRoles', array()); return parent::getRoles(); }