protected function flattenRoles(array $roles) { $roleNames = []; $iterator = $this->traversalStrategy->getRolesIterator($roles); foreach ($iterator as $role) { $roleNames[] = $role->getName(); } return array_unique($roleNames); }