tmgmt_smartling-8.x-4.11/modules/tmgmt_smartling_test/tmgmt_smartling_test.module

modules/tmgmt_smartling_test/tmgmt_smartling_test.module
<?php

/**
 * @file
 * Contains hook implementation for testing purposes.
 */

use Drupal\tmgmt\JobInterface;

function getUniqueFileName($file_name) {
  return substr(
    hash('sha256', Drupal::state()->get('tmgmt_smartling.bucket_name') . $file_name),
    0,
    12
  );
}

/**
 * Implements hook_user_login().
 */
function tmgmt_smartling_test_user_login($account) {
  Drupal::logger('tmgmt_smartling')->info('User @name has logged in.', [
    '@name' => $account->getDisplayName(),
  ]);
}

/**
 * Implements hook_user_logout().
 */
function tmgmt_smartling_test_user_logout($account) {
  Drupal::logger('tmgmt_smartling')->info('User @name has logged out.', [
    '@name' => $account->getDisplayName(),
  ]);
}

/**
 * Alter translation file name.
 *
 * @param string $name
 * @param JobInterface $job
 */
function tmgmt_smartling_test_tmgmt_smartling_filename_alter(&$name, JobInterface $job) {
  $name = getUniqueFileName($name);

  // Catch filenames we would need to delete after tests.
  $files_to_delete = Drupal::state()->get('tmgmt_smartling_test.files_to_delete', []);
  $files_to_delete[] = $name;

  Drupal::state()->set('tmgmt_smartling_test.files_to_delete', $files_to_delete);
}

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

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