You are here

function minisite_requirements in Mini site 7

Same name and namespace in other branches
  1. 8 minisite.install \minisite_requirements()

Implements hook_requirements().

File

./minisite.install, line 11
Contains install and update functions for Minisite.

Code

function minisite_requirements($phase) {
  $requirements = [];
  $t = get_t();
  $requirements['zip'] = [
    'title' => $t('Minisite'),
    'value' => $t('PHP Zip support required.'),
  ];

  // Ensure that the PHP Zip library is loaded.
  if (!extension_loaded('zip')) {
    $requirements['zip'] = [
      'description' => $t('The Minisite module requires the PHP module \'Zip\', but it is missing or not enabled on your server. This module allows PHP to work with ZIP compressed archives.<br>For more information visit: <a href="http://php.net/manual/en/book.zip.php">http://php.net/manual/en/book.zip.php</a>'),
      'severity' => REQUIREMENT_ERROR,
    ];
  }
  if ($phase == 'runtime') {
    $requirements['minisite_upload'] = [
      'title' => $t('Minisite upload directory'),
      'severity' => REQUIREMENT_OK,
      'value' => $t('Exists'),
    ];
    $requirements['minisite_static'] = [
      'title' => $t('Minisite static files directory'),
      'severity' => REQUIREMENT_OK,
      'value' => $t('Exists'),
    ];
    $path = 'public://minisite/upload';
    if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
      $requirements['minisite_upload']['description'] = $t('The Minisite upload directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', [
        '%path' => file_uri_target($path),
      ]);
      $requirements['minisite_upload']['severity'] = REQUIREMENT_ERROR;
      $requirements['minisite_upload']['value'] = $t('Unable to create');
    }
    $path = 'public://minisite/static';
    if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
      $requirements['minisite_static']['description'] = $t('The Minisite static files directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', [
        '%path' => file_uri_target($path),
      ]);
      $requirements['minisite_static']['severity'] = REQUIREMENT_ERROR;
      $requirements['minisite_static']['value'] = $t('Unable to create');
    }
  }
  return $requirements;
}