You are here

protected function CalendarViewsTrait::getTableEntityType in Calendar 8

1 call to CalendarViewsTrait::getTableEntityType()
CalendarViewsTrait::isTermReferenceField in src/CalendarViewsTrait.php
Determine if this field is Entity Reference field that references a taxonomy term.

File

src/CalendarViewsTrait.php, line 16

Class

CalendarViewsTrait
The trait.

Namespace

Drupal\calendar

Code

protected function getTableEntityType($table) {
  static $recursion = 0;
  if ($table = Views::viewsData()
    ->get($table)) {
    if (!empty($table['table']['entity type'])) {

      // Reset recursion when we found a value.
      $recursion = 0;
      return $table['table']['entity type'];
    }
    elseif (!empty($table['table']['join']) && count($table['table']['join']) == 1) {
      if (empty($recursion)) {
        $join_table = array_pop(array_keys($table['table']['join']));
        $recursion++;
        return $this
          ->getTableEntityType($join_table);
      }
    }
  }
  return NULL;
}