You are here

function advagg_ext_minify_requirements in Advanced CSS/JS Aggregation 8.4

Same name and namespace in other branches
  1. 8.2 advagg_ext_minify/advagg_ext_minify.install \advagg_ext_minify_requirements()
  2. 8.3 advagg_ext_minify/advagg_ext_minify.install \advagg_ext_minify_requirements()

Implements hook_requirements().

File

advagg_ext_minify/advagg_ext_minify.install, line 13
Install, update and uninstall functions for the advagg_ext_minify module.

Code

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;
}