You are here

advagg_ext_minify.install in Advanced CSS/JS Aggregation 8.3

Install, update and uninstall functions for the advagg_ext_minify module.

File

advagg_ext_minify/advagg_ext_minify.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the advagg_ext_minify module.
 */
use Drupal\Core\Cache\Cache;

/**
 * Implements hook_requirements().
 */
function advagg_ext_minify_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {

    // Check that php's shell_exec works. `ls` is pretty cross-platform.
    // Older Windows may not have it though so try `dir` as a backup.
    if (!@shell_exec('ls') && !@shell_exec('dir')) {
      $requirements['advagg_ext_min_shell_exec'] = [
        'title' => t('Advagg External Minification: PHP shell_exec'),
        'severity' => REQUIREMENT_ERROR,
        'value' => t('PHP shell_exec is non-functional.'),
        'description' => t('Check php.ini for safemode or <a href="@link" target="_blank">disable_functions</a>.', [
          '@link' => 'http://php.net/manual/en/ini.core.php#ini.disable-functions',
        ]),
      ];
    }
    else {
      $requirements['advagg_ext_min_shell_exec'] = [
        'title' => t('Advagg External Minification: PHP shell_exec'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Enabled'),
      ];
    }
  }
  return $requirements;
}

/**
 * Implements hook_install().
 *
 * Clear caches.
 */
function advagg_ext_minify_install() {
  Cache::invalidateTags([
    'library_info',
  ]);
  \Drupal::cache('render')
    ->invalidateAll();
}