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

    if (!$options) {
      $options = [
        'All' => $this->t('All'),
        'branches' => [],
        'camps' => [],
      ];
      $map = [
        'branch' => 'branches',
        'camp' => 'camps',
      ];
      $query = $this->entityQuery
        ->get('node')
        ->condition('status', 1)
        ->condition('type', ['branch', 'camp'], 'IN');
      $entity_ids = $query->execute();
      $nodes = $this->entityTypeManager->getStorage('node')
        ->loadMultiple($entity_ids);
      foreach ($nodes as $id => $node) {
        $options[$map[$node->bundle()]][$id] = $node->getTitle();
      }
      // Remove empty option categories.
      foreach ($options as $key => $option) {
        if (empty($option)) {
          unset($options[$key]);
        }
      }
    }

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

    if (!$options) {
      $options = [
        'All' => $this->t('All'),
        'branches' => [],
        'camps' => [],
      ];
      $map = [
        'branch' => 'branches',
        'camp' => 'camps',
      ];
      $query = $this->entityQuery
        ->get('node')
        ->condition('status', 1)
        ->condition('type', ['branch', 'camp'], 'IN');
      $entity_ids = $query->execute();
      $nodes = $this->entityTypeManager->getStorage('node')
        ->loadMultiple($entity_ids);
      foreach ($nodes as $id => $node) {
        $options[$map[$node->bundle()]][$id] = $node->getTitle();
      }
      // Remove empty option categories.
      foreach ($options as $key => $option) {
        if (empty($option)) {
          unset($options[$key]);
        }
      }
    }

    return $options;
  }
public function getLocationOptions ( ) { static $ options = [ ] ; if ( ! $ options ) { $ options = [ 'All' => $ this -> t ( 'All' ) , 'branches' => [ ] , 'camps' => [ ] , ] ; $ map = [ 'branch' => 'branches' , 'camp' => 'camps' , ] ; $ query = $ this -> entityQuery -> get ( 'node' ) -> condition ( 'status' , 1 ) -> condition ( 'type' , [ 'branch' , 'camp' ] , 'IN' ) ; $ entity_ids = $ query -> execute ( ) ; $ nodes = $ this -> entityTypeManager -> getStorage ( 'node' ) -> loadMultiple ( $ entity_ids ) ; foreach ( $ nodes as $ id => $ node ) { $ options [ $ map [ $ node -> bundle ( ) ] ] [ $ id ] = $ node -> getTitle ( ) ; } // Remove empty option categories. foreach ( $ options as $ key => $ option ) { if ( empty ( $ option ) ) { unset ( $ options [ $ key ] ) ; } } } return $ options ; }
Helper method retrieving location options.

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