You are here

function paragraphs_sets_requirements in Paragraphs Sets 8.2

Implements hook_requirements().

File

./paragraphs_sets.install, line 19
Installation hooks for paragraphs_setss module.

Code

function paragraphs_sets_requirements($phase) {
  $requirements = [];
  if (!in_array($phase, [
    'install',
    'runtime',
  ])) {
    return $requirements;
  }

  // Check version of paragraphs module.
  if (\Drupal::moduleHandler()
    ->moduleExists('paragraphs')) {
    $module_info = \Drupal::service('extension.list.module')
      ->getExtensionInfo('paragraphs');
    if (empty($module_info['version'])) {

      // Module checked out from git so we assume it is newer than required.
      return $requirements;
    }
    if (version_compare($module_info['version'], '8.x-1.3', '<')) {
      $requirements['paragraphs'] = [
        'title' => t('Paragraphs version'),
        'description' => t('You need to install at least version 8.x-1.3 of the %paragraphs module (installed version is %version).', [
          '%paragraphs' => 'Paragraphs',
          '%version' => $module_info['version'],
        ]),
        'value' => t('Incompatible version'),
        'severity' => REQUIREMENT_ERROR,
      ];
    }
  }
  return $requirements;
}