public function getCategories(array $nids) {

    $condition = TRUE; // Could feasibly want TRUE under different circumstances
    if($nids){
      $condition = "n.nid NOT IN (".implode(',', $nids).")";
    }

    $sql = "SELECT title 
            FROM {node_field_data} n
            WHERE n.type = 'activity'
            AND " . $condition . "
            AND n.status = '1'
            ORDER BY title ASC";

    $connection = \Drupal::database();
    $query = $connection->query($sql);
    $result = $query->fetchCol();
    natsort($result);
    return $result;
  }
public function getCategories(array $nids) {

    $condition = TRUE; // Could feasibly want TRUE under different circumstances
    if($nids){
      $condition = "n.nid NOT IN (".implode(',', $nids).")";
    }

    $sql = "SELECT title 
            FROM {node_field_data} n
            WHERE n.type = 'activity'
            AND " . $condition . "
            AND n.status = '1'
            ORDER BY title ASC";

    $connection = \Drupal::database();
    $query = $connection->query($sql);
    $result = $query->fetchCol();
    natsort($result);
    return $result;
  }
public function getCategories ( array $ nids ) { $ condition = TRUE ; // Could feasibly want TRUE under different circumstances if ( $ nids ) { $ condition = "n.nid NOT IN (" . implode ( ',' , $ nids ) . ")" ; } $ sql = "SELECT title 
            FROM {node_field_data} n
            WHERE n.type = 'activity'
            AND " . $ condition . "
            AND n.status = '1'
            ORDER BY title ASC" ; $ connection = \ Drupal :: database ( ) ; $ query = $ connection -> query ( $ sql ) ; $ result = $ query -> fetchCol ( ) ; natsort ( $ result ) ; return $ result ; }
Return Categories from chain "Session" -> "Class" -> "Activity" -> "Program sub-category".

@param array $nids
Array that contains categories nids to exclude.

@return array
Return Categories from chain Session - > Class - > Activity - > Program sub - category .