You are here

function media_entity_generic_requirements in Media entity generic 8

Implements hook_requirements().

File

./media_entity_generic.install, line 11
Install, uninstall and update hooks for Media Entity Generic module.

Code

function media_entity_generic_requirements($phase) {
  $requirements = [];

  // Prevent installation if Media Entity 1.x is enabled.
  if (\Drupal::moduleHandler()
    ->moduleExists('media_entity')) {
    $info = \Drupal::service('extension.list.module')
      ->getExtensionInfo('media_entity');
    if (version_compare($info['version'], '8.x-2') < 0) {
      $requirements['media_entity_generic_incompatibility'] = [
        'title' => t('Media'),
        'description' => t('The Media Entity Generic module is not compatible with contrib <a href=":url">Media Entity</a> 1.x branch. You don\'t need to enable this module manually, when performing the upgrade to Media in core, this module will be automatically enabled.', [
          ':url' => 'https://drupal.org/project/media_entity',
        ]),
        'severity' => REQUIREMENT_ERROR,
      ];
    }
  }
  return $requirements;
}