public function getClassOptions() {
    static $options = [];

    $category = $this->state['category'];
    if (!$options) {
      $options = ['all' => $this->t('All')];

      // Get activities ids.
      if ($category == 'all') {
        $categories_ids = array_keys($this->getCategoryOptions());
      }
      else {
        $categories_ids = [$category];
      }
      $query = $this->entityQuery
        ->get('node')
        ->condition('status', 1)
        ->condition('type', 'activity')
        ->condition('field_activity_category', $categories_ids, 'IN');
      $activities_ids = $query->execute();

      if ($activities_ids) {
        // Get classes.
        $query = $this->entityQuery
          ->get('node')
          ->condition('status', 1)
          ->condition('type', 'class')
          ->condition('field_class_activity', $activities_ids, 'IN')
          ->sort('title');
        $entity_ids = $query->execute();

        if ($entity_ids) {
          $nodes = $this->entityTypeManager->getStorage('node')->loadMultiple($entity_ids);
          foreach ($entity_ids as $id) {
            $options[$id] = $nodes[$id]->getTitle();
          }
        }
      }
    }

    return $options;
  }
public function getClassOptions() {
    static $options = [];

    $category = $this->state['category'];
    if (!$options) {
      $options = ['all' => $this->t('All')];

      // Get activities ids.
      if ($category == 'all') {
        $categories_ids = array_keys($this->getCategoryOptions());
      }
      else {
        $categories_ids = [$category];
      }
      $query = $this->entityQuery
        ->get('node')
        ->condition('status', 1)
        ->condition('type', 'activity')
        ->condition('field_activity_category', $categories_ids, 'IN');
      $activities_ids = $query->execute();

      if ($activities_ids) {
        // Get classes.
        $query = $this->entityQuery
          ->get('node')
          ->condition('status', 1)
          ->condition('type', 'class')
          ->condition('field_class_activity', $activities_ids, 'IN')
          ->sort('title');
        $entity_ids = $query->execute();

        if ($entity_ids) {
          $nodes = $this->entityTypeManager->getStorage('node')->loadMultiple($entity_ids);
          foreach ($entity_ids as $id) {
            $options[$id] = $nodes[$id]->getTitle();
          }
        }
      }
    }

    return $options;
  }
public function getClassOptions ( ) { static $ options = [ ] ; $ category = $ this -> state [ 'category' ] ; if ( ! $ options ) { $ options = [ 'all' => $ this -> t ( 'All' ) ] ; // Get activities ids. if ( $ category == 'all' ) { $ categories_ids = array_keys ( $ this -> getCategoryOptions ( ) ) ; } else { $ categories_ids = [ $ category ] ; } $ query = $ this -> entityQuery -> get ( 'node' ) -> condition ( 'status' , 1 ) -> condition ( 'type' , 'activity' ) -> condition ( 'field_activity_category' , $ categories_ids , 'IN' ) ; $ activities_ids = $ query -> execute ( ) ; if ( $ activities_ids ) { // Get classes. $ query = $ this -> entityQuery -> get ( 'node' ) -> condition ( 'status' , 1 ) -> condition ( 'type' , 'class' ) -> condition ( 'field_class_activity' , $ activities_ids , 'IN' ) -> sort ( 'title' ) ; $ entity_ids = $ query -> execute ( ) ; if ( $ entity_ids ) { $ nodes = $ this -> entityTypeManager -> getStorage ( 'node' ) -> loadMultiple ( $ entity_ids ) ; foreach ( $ entity_ids as $ id ) { $ options [ $ id ] = $ nodes [ $ id ] -> getTitle ( ) ; } } } } return $ options ; }
Helper method retrieving class options.

@return array
Array of class to be used in form element.
Helper method retrieving class options .