function entity_browser_requirements in Entity Browser 8.2
Implements hook_requirements().
File
- ./
entity_browser.install, line 11 - Update hooks for the Entity browser module.
Code
function entity_browser_requirements($phase) {
$requirements = [];
// This branch of Entity Browser shouldn't be used with core < 8.4.x or with
// media_entity 1.x enabled.
$incompatible = FALSE;
if (\Drupal::moduleHandler()
->moduleExists('media_entity')) {
$info = \Drupal::service('extension.list.module')
->getExtensionInfo('media_entity');
if (empty($info['version'])) {
// If the version being used is -dev, $info['version'] will be empty. Try
// an alternative method to detect if we are using the 2.x branch in that
// case.
if (!file_exists(DRUPAL_ROOT . '/' . drupal_get_path('module', 'media_entity') . '/src/CliService.php')) {
$incompatible = TRUE;
}
}
elseif (version_compare($info['version'], '8.x-2') < 0) {
$incompatible = TRUE;
}
}
if ($incompatible) {
$requirements['entity_browser_media'] = [
'title' => t('Entity Browser'),
'value' => t('This branch of Entity Browser is not compatible with the version of Media Entity installed.'),
'description' => t('This branch of Entity Browser is not compatible with the version of Media Entity installed.'),
'severity' => REQUIREMENT_ERROR,
];
}
return $requirements;
}