Skip to content
Snippets Groups Projects
Commit 158d942c authored by Wim Leers's avatar Wim Leers Committed by Adam G-H
Browse files

Issue #3345761 by Wim Leers, tedbow, phenaproxima: UpdateReleaseValidator...

Issue #3345761 by Wim Leers, tedbow, phenaproxima: UpdateReleaseValidator should use ComposerInspector instead of ComposerUtility
parent 15ae777b
No related branches found
No related tags found
No related merge requests found
services: services:
_defaults:
autowire: true
automatic_updates_extensions.updater: automatic_updates_extensions.updater:
class: Drupal\automatic_updates_extensions\ExtensionUpdater class: Drupal\automatic_updates_extensions\ExtensionUpdater
arguments: arguments:
......
...@@ -4,6 +4,8 @@ declare(strict_types = 1); ...@@ -4,6 +4,8 @@ declare(strict_types = 1);
namespace Drupal\automatic_updates_extensions\Validator; namespace Drupal\automatic_updates_extensions\Validator;
use Drupal\package_manager\ComposerInspector;
use Drupal\package_manager\PathLocator;
use Drupal\package_manager\ProjectInfo; use Drupal\package_manager\ProjectInfo;
use Drupal\automatic_updates_extensions\ExtensionUpdater; use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\package_manager\LegacyVersionUtility; use Drupal\package_manager\LegacyVersionUtility;
...@@ -24,6 +26,19 @@ final class UpdateReleaseValidator implements EventSubscriberInterface { ...@@ -24,6 +26,19 @@ final class UpdateReleaseValidator implements EventSubscriberInterface {
use StringTranslationTrait; use StringTranslationTrait;
/**
* Constructs an UpdateReleaseValidator object.
*
* @param \Drupal\package_manager\ComposerInspector $composerInspector
* The Composer inspector service.
* @param \Drupal\package_manager\PathLocator $pathLocator
* The path locator service.
*/
public function __construct(
private ComposerInspector $composerInspector,
private PathLocator $pathLocator
) {}
/** /**
* Checks if the given version of a project is supported. * Checks if the given version of a project is supported.
* *
...@@ -77,11 +92,12 @@ final class UpdateReleaseValidator implements EventSubscriberInterface { ...@@ -77,11 +92,12 @@ final class UpdateReleaseValidator implements EventSubscriberInterface {
return; return;
} }
$active_packages = $this->composerInspector->getInstalledPackagesList($this->pathLocator->getProjectRoot());
$all_versions = $stage->getPackageVersions(); $all_versions = $stage->getPackageVersions();
$messages = []; $messages = [];
foreach (['production', 'dev'] as $package_type) { foreach (['production', 'dev'] as $package_type) {
foreach ($all_versions[$package_type] as $package_name => $sematic_version) { foreach ($all_versions[$package_type] as $package_name => $sematic_version) {
$project_name = $stage->getActiveComposer()->getProjectForPackage($package_name); $project_name = $active_packages[$package_name]->getProjectName();
// If the version isn't in the list of installable releases, then it // If the version isn't in the list of installable releases, then it
// isn't secure and supported and the user should receive an error. // isn't secure and supported and the user should receive an error.
if (!$this->isSupportedRelease($project_name, $sematic_version)) { if (!$this->isSupportedRelease($project_name, $sematic_version)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment