You are here

private function InfoForm::getFileInfo in Advanced CSS/JS Aggregation 8.2

Same name and namespace in other branches
  1. 8.4 src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getFileInfo()
  2. 8.3 src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getFileInfo()

Get detailed info about the given filename.

Parameters

string $filename: Name of file to lookup.

Return value

array Returns an array of detailed info about this file.

2 calls to InfoForm::getFileInfo()
InfoForm::getFileInfoAjax in src/Form/InfoForm.php
Display file info via ajax callback.
InfoForm::getFileInfoSubmit in src/Form/InfoForm.php
Display file info in a drupal message.

File

src/Form/InfoForm.php, line 353

Class

InfoForm
View AdvAgg information for this site.

Namespace

Drupal\advagg\Form

Code

private function getFileInfo($filename) {

  // Strip quotes and trim.
  $filename = trim(str_replace([
    '"',
    "'",
  ], '', $filename));
  if (substr_compare($filename, 'css_', 0) > 0 || substr_compare($filename, 'js_', 0) > 0) {
    $results = array_column($this->advaggAggregates
      ->getAll(), NULL, 'uid');
    if (isset($results[$filename])) {
      return $results[$filename];
    }
    else {
      return "Aggregate name unrecognized, confirm spelling, otherwise likely a very old aggregate that has been expunged.";
    }
  }
  elseif ($data = $this->advaggFiles
    ->get($filename)) {
    $data['File modification date'] = $this->dateFormatter
      ->format($data['mtime'], 'html_datetime');
    $data['Information last update'] = $this->dateFormatter
      ->format($data['updated'], 'html_datetime');
    return $data;
  }
  else {
    return "File not found and AdvAgg has no record of it. Confirm spelling of the path.";
  }
}