From 02b0e7716bde3be391b992274592e76c53dd9c77 Mon Sep 17 00:00:00 2001
From: Lavanya Talwar <69731-lavanyatalwar@users.noreply.drupalcode.org>
Date: Mon, 6 Jan 2025 20:28:30 +0000
Subject: [PATCH] Issue #3495318: Remove the ability for the
 project_browser.browse route to take a project ID

---
 .cspell-project-words.txt                  |  2 ++
 project_browser.routing.yml                |  3 +--
 src/Controller/BrowserController.php       |  6 +-----
 src/Element/ProjectBrowser.php             | 20 +++++++-------------
 src/Plugin/Derivative/LocalTaskDeriver.php |  1 -
 5 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt
index 3c907a818..39b3e6e82 100644
--- a/.cspell-project-words.txt
+++ b/.cspell-project-words.txt
@@ -13,3 +13,5 @@ NOCHANGES
 CURLOPT
 RETURNTRANSFER
 varchar
+techdebt
+
diff --git a/project_browser.routing.yml b/project_browser.routing.yml
index 206732109..3d25b6134 100644
--- a/project_browser.routing.yml
+++ b/project_browser.routing.yml
@@ -19,11 +19,10 @@ project_browser.api_project_get_all:
   #options:
   #  no_cache: 'TRUE'
 project_browser.browse:
-  path: '/admin/modules/browse/{source}/{id}'
+  path: '/admin/modules/browse/{source}'
   defaults:
     _controller: '\Drupal\project_browser\Controller\BrowserController::browse'
     _title: 'Browse projects'
-    id: null
   requirements:
     _permission: 'administer modules'
 project_browser.settings:
diff --git a/src/Controller/BrowserController.php b/src/Controller/BrowserController.php
index f1a8ae13f..0f1a7a736 100644
--- a/src/Controller/BrowserController.php
+++ b/src/Controller/BrowserController.php
@@ -26,18 +26,14 @@ class BrowserController extends ControllerBase {
    *
    * @param string $source
    *   The ID of the source plugin to query for projects.
-   * @param string|null $id
-   *   If viewing a specific project, the project's local ID (as known to the
-   *   source plugin).
    *
    * @return array
    *   A render array.
    */
-  public function browse(string $source, ?string $id): array {
+  public function browse(string $source): array {
     return [
       '#type' => 'project_browser',
       '#source' => $source,
-      '#id' => $id,
     ];
   }
 
diff --git a/src/Element/ProjectBrowser.php b/src/Element/ProjectBrowser.php
index 1c91b87b9..4175ba27b 100644
--- a/src/Element/ProjectBrowser.php
+++ b/src/Element/ProjectBrowser.php
@@ -97,8 +97,7 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn
    */
   public function attachProjectBrowserSettings(array $element): array {
     $element['#attached']['drupalSettings']['project_browser'] = $this->getDrupalSettings(
-      $element['#source'],
-      $element['#id'] ?? NULL
+      $element['#source']
     );
     return $element;
   }
@@ -108,14 +107,11 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn
    *
    * @param string $source
    *   The ID of the source plugin to query for projects.
-   * @param string|null $id
-   *   If viewing a specific project, the project's local ID (as known to the
-   *   source plugin).
    *
    * @return array
    *   An array of Drupal settings.
    */
-  private function getDrupalSettings(string $source, ?string $id): array {
+  private function getDrupalSettings(string $source): array {
     $current_sources = [
       $source => $this->enabledSourceHandler->getCurrentSources()[$source],
     ];
@@ -126,13 +122,11 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn
       'warnings' => [],
       'status_checked' => FALSE,
     ];
-    if (empty($id)) {
-      // @todo Fix https://www.drupal.org/node/3497624 to avoid adding
-      // hard-coded values. #techdebt
-      if ($source !== 'recipes' && $package_manager['available']) {
-        $package_manager = array_merge($package_manager, $this->installReadiness->validatePackageManager());
-        $package_manager['status_checked'] = TRUE;
-      }
+    // @todo Fix https://www.drupal.org/node/3497624 to avoid adding
+    // hard-coded values. #techdebt
+    if ($source !== 'recipes' && $package_manager['available']) {
+      $package_manager = array_merge($package_manager, $this->installReadiness->validatePackageManager());
+      $package_manager['status_checked'] = TRUE;
     }
 
     return [
diff --git a/src/Plugin/Derivative/LocalTaskDeriver.php b/src/Plugin/Derivative/LocalTaskDeriver.php
index cb2d31d4a..11e8b20ce 100644
--- a/src/Plugin/Derivative/LocalTaskDeriver.php
+++ b/src/Plugin/Derivative/LocalTaskDeriver.php
@@ -49,7 +49,6 @@ final class LocalTaskDeriver extends DeriverBase implements ContainerDeriverInte
         $source_id = $source->getPluginId();
         $local_task['route_parameters'] = [
           'source' => $source_id,
-          'id' => NULL,
         ];
         $derivative_id = str_replace($source::DERIVATIVE_SEPARATOR, '__', $source_id);
         $this->derivatives[$derivative_id] = $local_task;
-- 
GitLab