original_string: private function compileUserRoles()
      {
          if ($this->userRoles !== null) {
              return;
          }
  
          if (!$this->user) {
              $this->userRoles = [];
  
              return;
          }
  
          $roleList = [];
          $roleExpansion = [];
  
          /** @var Role $role */
          foreach ($this->roleProvider->getAllRoles() as $role) {
              $roleList[$role->getId()] = $role;
          }
  
          /** @var Role $userRole */
          $userRoles = $this->user->getRoles();
          if ($userRoles) {
              foreach ($userRoles as $userRole) {
                  $roleExpansion[] = $userRole->getName();
  
                  $parentRole = $userRole->getParent();
                  while ($parentRole) {
                      $roleExpansion[] = $parentRole->getName();
                      $parentRole = $parentRole->getParent();
                  }
              }
          }
          $this->userRoles = array_unique($roleExpansion);
      }
code: private function compileUserRoles()
      {
          if ($this->userRoles !== null) {
              return;
          }
  
          if (!$this->user) {
              $this->userRoles = [];
  
              return;
          }
  
          $roleList = [];
          $roleExpansion = [];
  
          /** @var Role $role */
          foreach ($this->roleProvider->getAllRoles() as $role) {
              $roleList[$role->getId()] = $role;
          }
  
          /** @var Role $userRole */
          $userRoles = $this->user->getRoles();
          if ($userRoles) {
              foreach ($userRoles as $userRole) {
                  $roleExpansion[] = $userRole->getName();
  
                  $parentRole = $userRole->getParent();
                  while ($parentRole) {
                      $roleExpansion[] = $parentRole->getName();
                      $parentRole = $parentRole->getParent();
                  }
              }
          }
          $this->userRoles = array_unique($roleExpansion);
      }
code_tokens: private function compileUserRoles ( ) { if ( $ this -> userRoles !== null ) { return ; } if ( ! $ this -> user ) { $ this -> userRoles = [ ] ; return ; } $ roleList = [ ] ; $ roleExpansion = [ ] ; /** @var Role $role */ foreach ( $ this -> roleProvider -> getAllRoles ( ) as $ role ) { $ roleList [ $ role -> getId ( ) ] = $ role ; } /** @var Role $userRole */ $ userRoles = $ this -> user -> getRoles ( ) ; if ( $ userRoles ) { foreach ( $ userRoles as $ userRole ) { $ roleExpansion [ ] = $ userRole -> getName ( ) ; $ parentRole = $ userRole -> getParent ( ) ; while ( $ parentRole ) { $ roleExpansion [ ] = $ parentRole -> getName ( ) ; $ parentRole = $ parentRole -> getParent ( ) ; } } } $ this -> userRoles = array_unique ( $ roleExpansion ) ; }
docstring: Flattens roles using the roleProvider, for quick lookup.
docstring_tokens: Flattens roles using the roleProvider for quick lookup .