You are here

class AssetsDataCollector in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/AssetsDataCollector.php \Drupal\webprofiler\DataCollector\AssetsDataCollector
  2. 8 webprofiler/src/DataCollector/AssetsDataCollector.php \Drupal\webprofiler\DataCollector\AssetsDataCollector
  3. 8.2 webprofiler/src/DataCollector/AssetsDataCollector.php \Drupal\webprofiler\DataCollector\AssetsDataCollector

Collects data about the used assets (CSS/JS).

Hierarchy

Expanded class hierarchy of AssetsDataCollector

3 files declare their use of AssetsDataCollector
AssetsDataCollectorTest.php in webprofiler/tests/src/Unit/DataCollector/AssetsDataCollectorTest.php
CssCollectionRendererWrapper.php in webprofiler/src/Asset/CssCollectionRendererWrapper.php
JsCollectionRendererWrapper.php in webprofiler/src/Asset/JsCollectionRendererWrapper.php
1 string reference to 'AssetsDataCollector'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses AssetsDataCollector
webprofiler.assets in webprofiler/webprofiler.services.yml
Drupal\webprofiler\DataCollector\AssetsDataCollector

File

webprofiler/src/DataCollector/AssetsDataCollector.php, line 15

Namespace

Drupal\webprofiler\DataCollector
View source
class AssetsDataCollector extends DataCollector implements DrupalDataCollectorInterface {
  use StringTranslationTrait, DrupalDataCollectorTrait;

  /**
   * The app root.
   *
   * @var string
   */
  protected $root;

  /**
   * Constructs a AssetDataCollector object.
   *
   * @param string $root
   *   The app root.
   */
  public function __construct($root) {
    $this->root = $root;
    $this->data['js'] = [];
    $this->data['css'] = [];
  }

  /**
   * {@inheritdoc}
   */
  public function collect(Request $request, Response $response, \Exception $exception = NULL) {
    $this->data['assets']['installation_path'] = $this->root . '/';
  }

  /**
   * @param $jsAsset
   */
  public function addJsAsset($jsAsset) {
    $this->data['js'] = NestedArray::mergeDeepArray([
      $jsAsset,
      $this->data['js'],
    ]);
  }

  /**
   * @param $cssAsset
   */
  public function addCssAsset($cssAsset) {
    $this->data['css'] = NestedArray::mergeDeepArray([
      $cssAsset,
      $this->data['css'],
    ]);
  }

  /**
   * Twig callback to return the amount of CSS files.
   */
  public function getCssCount() {
    return count($this->data['css']);
  }

  /**
   * Twig callback to return the amount of JS files.
   */
  public function getJsCount() {
    return count($this->data['js']) - 1;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'assets';
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('Assets');
  }

  /**
   * {@inheritdoc}
   */
  public function getPanelSummary() {
    return $this
      ->t('Total: @count', [
      '@count' => $this
        ->getCssCount() + $this
        ->getJsCount(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getIcon() {
    return 'iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAYAAACOGPReAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgU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gNVqZfV9J586lUBtMplgLpdDEoyktuj1ejEej7M1p9OJbrcbi8UirtdrNjebzQ6MN/KPfT6f436/Z3XudDp4e3uLlUqFQej37XbL5B7DjqEfthQBAgGzfpTJZJDNZpn0zWbDRgI/eQlOdjGFU1coFIfHGu3Lv90qbrfbXRFpJ4POAVGjh/r09PRCP38l3r3Q62RA/NtV3qb8T/Nn4irQXwIMANMNuV/Q8qbhAAAAAElFTkSuQmCC';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssetsDataCollector::$root protected property The app root.
AssetsDataCollector::addCssAsset public function
AssetsDataCollector::addJsAsset public function
AssetsDataCollector::collect public function
AssetsDataCollector::getCssCount public function Twig callback to return the amount of CSS files.
AssetsDataCollector::getIcon public function Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface::getIcon
AssetsDataCollector::getJsCount public function Twig callback to return the amount of JS files.
AssetsDataCollector::getName public function Returns the name of the collector. Overrides DrupalDataCollectorInterface::getName
AssetsDataCollector::getPanelSummary public function Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface::getPanelSummary
AssetsDataCollector::getTitle public function Returns the datacollector title. Overrides DrupalDataCollectorInterface::getTitle
AssetsDataCollector::__construct public function Constructs a AssetDataCollector object.
DrupalDataCollectorInterface::getData public function 8
DrupalDataCollectorInterface::getDrupalSettings public function 1
DrupalDataCollectorInterface::getLibraries public function Returns the libraries needed in detail panel. 2
DrupalDataCollectorInterface::hasPanel public function Returns true if this datacollector has a detail panel. 2
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.