You are here

protected function SensorDatabaseAggregator::getEntityTypeFromTable in Monitoring 7

Returns the entity type for a given base table.

Parameters

string $base_table: The name of base table.

Return value

string The entity type that is stored in the given base table.

Throws

\InvalidArgumentException Thrown if the table does not belong to any entity type.

1 call to SensorDatabaseAggregator::getEntityTypeFromTable()
SensorDatabaseAggregator::getFieldName in lib/Drupal/monitoring/Sensor/Sensors/SensorDatabaseAggregator.php
Returns the field name to use for a condition and ensures necessary joins.

File

lib/Drupal/monitoring/Sensor/Sensors/SensorDatabaseAggregator.php, line 220
Contains \Drupal\monitoring\Sensor\Sensors\SensorDatabaseAggregator.

Class

SensorDatabaseAggregator
Base for database aggregator sensors.

Namespace

Drupal\monitoring\Sensor\Sensors

Code

protected function getEntityTypeFromTable($base_table) {
  foreach (entity_get_info() as $entity_type => $entity_info) {
    if (isset($entity_info['base table']) && $entity_info['base table'] == $base_table) {
      return $entity_type;
    }
  }

  // If we failed to find the entity type, abort.
  throw new \InvalidArgumentException(format_string('No entity type found for table @table', array(
    '@table' => $this->info
      ->getSetting('table'),
  )));
}