Skip to content
Snippets Groups Projects
Commit 02b0e771 authored by Lavanya Talwar's avatar Lavanya Talwar Committed by Chris Wells
Browse files

Issue #3495318: Remove the ability for the project_browser.browse route to take a project ID

parent ea54f920
No related branches found
No related tags found
1 merge request!655#Issue:3495318-Removed the ability for the browse route to take a project ID
Pipeline #387736 failed
...@@ -13,3 +13,5 @@ NOCHANGES ...@@ -13,3 +13,5 @@ NOCHANGES
CURLOPT CURLOPT
RETURNTRANSFER RETURNTRANSFER
varchar varchar
techdebt
...@@ -19,11 +19,10 @@ project_browser.api_project_get_all: ...@@ -19,11 +19,10 @@ project_browser.api_project_get_all:
#options: #options:
# no_cache: 'TRUE' # no_cache: 'TRUE'
project_browser.browse: project_browser.browse:
path: '/admin/modules/browse/{source}/{id}' path: '/admin/modules/browse/{source}'
defaults: defaults:
_controller: '\Drupal\project_browser\Controller\BrowserController::browse' _controller: '\Drupal\project_browser\Controller\BrowserController::browse'
_title: 'Browse projects' _title: 'Browse projects'
id: null
requirements: requirements:
_permission: 'administer modules' _permission: 'administer modules'
project_browser.settings: project_browser.settings:
......
...@@ -26,18 +26,14 @@ class BrowserController extends ControllerBase { ...@@ -26,18 +26,14 @@ class BrowserController extends ControllerBase {
* *
* @param string $source * @param string $source
* The ID of the source plugin to query for projects. * 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 * @return array
* A render array. * A render array.
*/ */
public function browse(string $source, ?string $id): array { public function browse(string $source): array {
return [ return [
'#type' => 'project_browser', '#type' => 'project_browser',
'#source' => $source, '#source' => $source,
'#id' => $id,
]; ];
} }
......
...@@ -97,8 +97,7 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn ...@@ -97,8 +97,7 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn
*/ */
public function attachProjectBrowserSettings(array $element): array { public function attachProjectBrowserSettings(array $element): array {
$element['#attached']['drupalSettings']['project_browser'] = $this->getDrupalSettings( $element['#attached']['drupalSettings']['project_browser'] = $this->getDrupalSettings(
$element['#source'], $element['#source']
$element['#id'] ?? NULL
); );
return $element; return $element;
} }
...@@ -108,14 +107,11 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn ...@@ -108,14 +107,11 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn
* *
* @param string $source * @param string $source
* The ID of the source plugin to query for projects. * 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 * @return array
* An array of Drupal settings. * An array of Drupal settings.
*/ */
private function getDrupalSettings(string $source, ?string $id): array { private function getDrupalSettings(string $source): array {
$current_sources = [ $current_sources = [
$source => $this->enabledSourceHandler->getCurrentSources()[$source], $source => $this->enabledSourceHandler->getCurrentSources()[$source],
]; ];
...@@ -126,13 +122,11 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn ...@@ -126,13 +122,11 @@ final class ProjectBrowser implements ElementInterface, ContainerFactoryPluginIn
'warnings' => [], 'warnings' => [],
'status_checked' => FALSE, 'status_checked' => FALSE,
]; ];
if (empty($id)) { // @todo Fix https://www.drupal.org/node/3497624 to avoid adding
// @todo Fix https://www.drupal.org/node/3497624 to avoid adding // hard-coded values. #techdebt
// hard-coded values. #techdebt if ($source !== 'recipes' && $package_manager['available']) {
if ($source !== 'recipes' && $package_manager['available']) { $package_manager = array_merge($package_manager, $this->installReadiness->validatePackageManager());
$package_manager = array_merge($package_manager, $this->installReadiness->validatePackageManager()); $package_manager['status_checked'] = TRUE;
$package_manager['status_checked'] = TRUE;
}
} }
return [ return [
......
...@@ -49,7 +49,6 @@ final class LocalTaskDeriver extends DeriverBase implements ContainerDeriverInte ...@@ -49,7 +49,6 @@ final class LocalTaskDeriver extends DeriverBase implements ContainerDeriverInte
$source_id = $source->getPluginId(); $source_id = $source->getPluginId();
$local_task['route_parameters'] = [ $local_task['route_parameters'] = [
'source' => $source_id, 'source' => $source_id,
'id' => NULL,
]; ];
$derivative_id = str_replace($source::DERIVATIVE_SEPARATOR, '__', $source_id); $derivative_id = str_replace($source::DERIVATIVE_SEPARATOR, '__', $source_id);
$this->derivatives[$derivative_id] = $local_task; $this->derivatives[$derivative_id] = $local_task;
......
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