/** * Adds a role to this account * * @param Role $role * @return void * @throws \InvalidArgumentException * @api */ public function addRole(Role $role) { if ($role->isAbstract()) { throw new \InvalidArgumentException(sprintf('Abstract roles can\'t be assigned to accounts directly, but the role "%s" is marked abstract', $role->getIdentifier()), 1399900657); } $this->initializeRoles(); if (!$this->hasRole($role)) { $roleIdentifier = $role->getIdentifier(); $this->roleIdentifiers[] = $roleIdentifier; $this->roles[$roleIdentifier] = $role; } }