qtools_profiler-8.x-1.x-dev/modules/qtools_cache_profiler/qtools_cache_profiler.module

modules/qtools_cache_profiler/qtools_cache_profiler.module
<?php

/**
 * @file
 * Module hooks.
 */

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\qtools_cache_profiler\Ajax\RenderCacheStatsCommand;

/**
 * Implements hook_qtools_profiler_finish().
 */
function qtools_cache_profiler_qtools_profiler_finish($rid) {
  /** @var \Drupal\qtools_cache_profiler\PlaceholderingRenderCacheWrapper $renderCachewrapper */
  $placeholderingRenderCacheWrapper = \Drupal::service('render_cache');
  $render_cache_stats = $placeholderingRenderCacheWrapper->getPerformanceStats();

  /** @var \Drupal\qtools_cache_profiler\PerformanceService $performanceService */
  $performanceService = \Drupal::service('qtools_cache_profiler.performance');
  $performanceService->saveRenderCacheStats($rid, $render_cache_stats);
}

/**
 * Implements hook_qtools_profiler_preview_reports_alter().
 */
function qtools_cache_profiler_qtools_profiler_preview_reports_alter(&$preview_reports, &$attachments) {
  $preview_reports[] = ['#qtools_cache_profiler_render_cache', t('Render Cache')];

  $moduleHandler = \Drupal::moduleHandler();
  if ($moduleHandler->moduleExists('renderviz')) {
    $attachments['library'][] = 'qtools_cache_profiler/cache-profiler-preview';
  }
  else {
    $attachments['library'][] = 'qtools_cache_profiler/cache-profiler-preview-renderviz';
  }
}

/**
 * Implements qtools_profiler_request_summary_response_alter().
 */
function qtools_cache_profiler_qtools_profiler_request_summary_response_alter(AjaxResponse $response, $rid) {
  /** @var \Drupal\qtools_cache_profiler\PerformanceService $performanceService */
  $performanceService = \Drupal::service('qtools_cache_profiler.performance');
  $render_cache_stats = $performanceService->getRenderCacheStats($rid);

  $response->addCommand(new RenderCacheStatsCommand($render_cache_stats));
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc