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

modules/qtools_profiler_example/qtools_profiler_example.module
<?php

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

/**
 * Implements hook_qtools_profiler_finish().
 */
function qtools_profiler_example_qtools_profiler_finish($rid) {
  /** @var \Drupal\qtools_profiler_example\PerformanceService $performanceService */
  $performanceService = \Drupal::service('qtools_profiler_example.performance');

  // Load performance statistic.
  $performance_stat = $performanceService->getEntityLoadsCount();

  // Save performance statistic.
  $performanceService->savePerformanceStats($rid, $performance_stat);
}

/**
 * Implements hook_entity_load().
 */
function qtools_profiler_example_entity_load(array $entities, $entity_type_id) {
  /** @var \Drupal\qtools_profiler_example\PerformanceService $performanceService */
  $performanceService = \Drupal::service('qtools_profiler_example.performance');
  $performanceService->trackEntityLoad();
}

/**
 * Implements hook_qtools_profiler_flush().
 */
function qtools_profiler_example_qtools_profiler_flush() {
  /** @var \Drupal\qtools_profiler_example\PerformanceService $performanceService */
  $performanceService = \Drupal::service('qtools_profiler_example.performance');
  $performanceService->flush();
}

/**
 * Implements hook_qtools_profiler_cleanup().
 */
function qtools_profiler_example_qtools_profiler_cleanup($id) {
  /** @var \Drupal\qtools_profiler_example\PerformanceService $performanceService */
  $performanceService = \Drupal::service('qtools_profiler_example.performance');
  $performanceService->cleanup($id);
}

/**
 * Implements hook_qtools_profiler_preview_reports_alter().
 */
function qtools_profiler_example_qtools_profiler_preview_reports_alter(&$preview_reports) {
  $preview_reports[] = ['/admin/config/development/qtools_profiler/preview/entities?request={id}', t('Entity loads')];
}

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

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