Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.7.x
Introduced in version:
8.7.x
Issue links:
Description:
Functionality from drupal_check_incompatibility()
and \Drupal\Core\Extension\ModuleHandler::parseDependency()
has moved to Drupal\Core\Extension\Dependency
.
In support of this there is a new drupal/core-version
component with a single class, Drupal\Component\Version\Constraint
that provides functionality to parse and perform checks against constraint strings like >8.x-1.1
.
Additionally, the public requires
property of Extension
objects returned by \Drupal::service('extension.list.module')->reset()->getList()
now contains Dependency
objects.
Before
$v = \Drupal::moduleHandler()->parseDependency('paragraphs:paragraphs (>8.x-1.3)');
// $version will equal ' (>8.x-1.3)'.
$version = drupal_check_incompatibility($v, '1.2');
$module_list = \Drupal::service('extension.list.module')->getList();
// Assuming the paragraphs_demo module has a dependency like 'paragraphs:paragraphs (>8.x-1.3)'.
$version_info = $module_list['paragraphs_demo']->requires['paragraphs'];
// $version will equal ' (>8.x-1.3)'.
$version = drupal_check_incompatibility($version_info, '1.2');
After
$dependency = Dependency::createFromString('paragraphs:paragraphs (>8.x-1.3)');
if (!$dependency->isCompatible('1.2')) {
// $constraint will equal '>8.x-1.3'.
$constraint = $dependency->getConstraintString()
}
$module_list = \Drupal::service('extension.list.module')->getList();
// Assuming the paragraphs_demo module has a dependency like 'paragraphs:paragraphs (>8.x-1.3)'.
if ($module_list['paragraphs_demo']->requires['paragraphs']->isCompatible('1.2')) {
// $constraint will equal '>8.x-1.3'.
$constraint = $module_list['paragraphs_demo']->requires['paragraphs']->getConstraintString();
}
Impacts:
Module developers