You are here

public function SensorImageMissingStyle::resultVerbose in Monitoring 7

Provide additional info about sensor call.

Parameters

SensorResultInterface $result: Sensor result.

Return value

string Sensor call verbose info.

Overrides SensorDatabaseAggregator::resultVerbose

File

lib/Drupal/monitoring/Sensor/Sensors/SensorImageMissingStyle.php, line 55
Contains \Drupal\monitoring\Sensor\Sensors\SensorImageMissingStyle.

Class

SensorImageMissingStyle
Monitors image derivate creation errors from dblog.

Namespace

Drupal\monitoring\Sensor\Sensors

Code

public function resultVerbose(SensorResultInterface $result) {
  $verbose = parent::resultVerbose($result);

  // If non found, no reason to query file_managed table.
  if ($result
    ->getValue() == 0) {
    return $verbose;
  }

  // In case we were not able to retrieve this info from the watchdog
  // variables.
  if (empty($this->sourceImagePath)) {
    $message = t('Source image path is empty, cannot query file_managed table');
  }
  $file = db_query('SELECT * FROM file_managed WHERE uri = :uri', array(
    ':uri' => $this->sourceImagePath,
  ))
    ->fetchObject();
  if (!empty($file)) {
    $message = t('File managed records: <pre>@file_managed</pre>', array(
      '@file_managed' => var_export(file_usage_list($file), TRUE),
    ));
  }
  if (empty($message)) {
    $message = t('File @file record not found in the file_managed table.', array(
      '@file' => $result
        ->getMessage(),
    ));
  }
  $verbose .= ' ' . $message;
  return $verbose;
}