You are here

tacjs.install in TacJS 8

Same filename and directory in other branches
  1. 8.2 tacjs.install
  2. 8.5 tacjs.install

Install, update and uninstall functions for the tacjs module.

File

tacjs.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the tacjs module.
 */

/**
 * Implements hook_requirements().
 */
function tacjs_requirements($phase) {
  $requirements = [];
  $path = DRUPAL_ROOT . '/libraries/tarteaucitron/tarteaucitron.js';
  $path_service = DRUPAL_ROOT . '/libraries/tarteaucitron/tarteaucitron.services.js';
  if (\Drupal::moduleHandler()
    ->moduleExists('libraries')) {
    $path = libraries_get_path('tarteaucitron') . '/tarteaucitron/tarteaucitron.js';
    $path_service = libraries_get_path('tarteaucitron') . '/tarteaucitron/tarteaucitron.services.js';
  }

  // Is the library found in the root libraries path.
  $library_found = file_exists($path);
  $library_found_s = file_exists($path_service);

  // If library is not found, then look in the current profile libraries path.
  if (!$library_found && !$library_found_s) {
    $profile_path = drupal_get_path('profile', drupal_get_profile());
    $profile_path .= '/libraries/tarteaucitron/tarteaucitron.js';

    // Is the library found in the current profile libraries path.
    $library_found = file_exists($profile_path);
  }
  if (!$library_found && !$library_found_s) {
    $requirements['tacjs_library'] = [
      'title' => t('Tac js  library missing'),
      'description' => t('Tacjs requires the tarteaucitron library.
        Download it (https://github.com/AmauriC/tarteaucitron.js/), rename directory to tarteaucitron and place it in the
        libraries folder (/libraries)'),
      'severity' => REQUIREMENT_ERROR,
    ];
  }
  return $requirements;
}

Functions

Namesort descending Description
tacjs_requirements Implements hook_requirements().