diff --git a/src/ResourceType/ConfigurableResourceTypeRepository.php b/src/ResourceType/ConfigurableResourceTypeRepository.php index c377969e29d35b942cb95def17e6cd37be41e429..8baf8e6c1d6a5087bf74e342f7f64e9d382fbfe1 100644 --- a/src/ResourceType/ConfigurableResourceTypeRepository.php +++ b/src/ResourceType/ConfigurableResourceTypeRepository.php @@ -73,15 +73,23 @@ class ConfigurableResourceTypeRepository extends ResourceTypeRepository { * @todo Remove this when JSON API Extras drops support for JSON API 1.x. */ public static function isJsonApi2x() { - static $result = NULL; + static $is_2x = NULL; - if ($result === NULL) { - $v = ModuleHandler::parseDependency('jsonapi(>= 8.x-2.0-beta1)'); - $module_list = \Drupal::service('extension.list.module')->getList(); - $result = NULL === drupal_check_incompatibility($v, $module_list['jsonapi']->info['version']); + if ($is_2x !== NULL) { + return $is_2x; } - - return $result; + $extension = \Drupal::service('extension.list.module')->get('jsonapi'); + $version = $extension->info['version']; + if ($version === NULL) { + // When running a git clone of the module we will not get a version number + // here. In this case we resort to checking for a 2.x only service. + $is_2x = \Drupal::hasService('jsonapi.include_resolver'); + } + else { + $dependency = ModuleHandler::parseDependency('jsonapi(>= 8.x-2.0-beta1)'); + $is_2x = drupal_check_incompatibility($dependency, $version) === NULL; + } + return $is_2x; } /**