Skip to content
Snippets Groups Projects
Commit dd646952 authored by Adam G-H's avatar Adam G-H
Browse files

Pass stage ID to inProgress controller

parent ef00fb99
No related branches found
No related tags found
No related merge requests found
...@@ -127,6 +127,8 @@ class InstallerController extends ControllerBase { ...@@ -127,6 +127,8 @@ class InstallerController extends ControllerBase {
* *
* @param string $project_id * @param string $project_id
* The project machine name. * The project machine name.
* @param string|null $stage_id
* (optional) The installer stage ID, if there is one. Defaults to NULL.
* *
* @return \Symfony\Component\HttpFoundation\JsonResponse * @return \Symfony\Component\HttpFoundation\JsonResponse
* Information about the project's require/install status. * Information about the project's require/install status.
...@@ -138,20 +140,25 @@ class InstallerController extends ControllerBase { ...@@ -138,20 +140,25 @@ class InstallerController extends ControllerBase {
* regularly so it can monitor the progress of the process and report which * regularly so it can monitor the progress of the process and report which
* stage is taking place. * stage is taking place.
*/ */
public function inProgress(string $project_id): JsonResponse { public function inProgress(string $project_id, ?string $stage_id = NULL): JsonResponse {
$requiring = $this->installer->getMetadata('requiring');
// @see ::activateModule() // @see ::activateModule()
$core_installing = $this->keyValue->get('installing'); $core_installing = $this->keyValue->get('installing');
if ($core_installing === $project_id) {
return new JsonResponse(['status' => self::STATUS_INSTALLING_PROJECT]);
}
$return = ['status' => self::STATUS_IDLE]; $return = ['status' => self::STATUS_IDLE];
if (isset($requiring['project_id']) && $requiring['project_id'] === $project_id) { // If the installer is available, we're idle.
$return['status'] = self::STATUS_REQUIRING_PROJECT; if ($this->installer->isAvailable()) {
$return['phase'] = $requiring['phase']; return new JsonResponse($return);
} }
if ($core_installing === $project_id) { elseif ($stage_id) {
$return['status'] = self::STATUS_INSTALLING_PROJECT; $requiring = $this->installer->claim($stage_id)->getMetadata('requiring');
if (isset($requiring['project_id']) && $requiring['project_id'] === $project_id) {
$return['status'] = self::STATUS_REQUIRING_PROJECT;
$return['phase'] = $requiring['phase'];
}
} }
return new JsonResponse($return); return new JsonResponse($return);
} }
......
...@@ -129,10 +129,11 @@ class ProjectBrowserRoutes implements ContainerInjectionInterface { ...@@ -129,10 +129,11 @@ class ProjectBrowserRoutes implements ContainerInjectionInterface {
], ],
); );
$routes['project_browser.module.install_in_progress'] = new Route( $routes['project_browser.module.install_in_progress'] = new Route(
'/admin/modules/project_browser/install_in_progress/{project_id}', '/admin/modules/project_browser/install_in_progress/{project_id}/{stage_id}',
[ [
'_controller' => InstallerController::class . '::inProgress', '_controller' => InstallerController::class . '::inProgress',
'_title' => 'Install in progress', '_title' => 'Install in progress',
'stage_id' => NULL,
], ],
[ [
'_permission' => 'administer modules', '_permission' => 'administer modules',
......
...@@ -523,7 +523,7 @@ class InstallerControllerTest extends BrowserTestBase { ...@@ -523,7 +523,7 @@ class InstallerControllerTest extends BrowserTestBase {
$expect_install['stage_id'] = $this->stageId; $expect_install['stage_id'] = $this->stageId;
} }
$this->assertProjectBrowserTempStatus($expect_install, NULL); $this->assertProjectBrowserTempStatus($expect_install, NULL);
$this->drupalGet("/admin/modules/project_browser/install_in_progress/$module"); $this->drupalGet("/admin/modules/project_browser/install_in_progress/$module/$this->stageId");
$this->assertSame(sprintf('{"status":1,"phase":"%s"}', $phase), $this->getSession()->getPage()->getContent()); $this->assertSame(sprintf('{"status":1,"phase":"%s"}', $phase), $this->getSession()->getPage()->getContent());
$this->drupalGet('/admin/modules/project_browser/install_in_progress/metatag'); $this->drupalGet('/admin/modules/project_browser/install_in_progress/metatag');
$this->assertSame('{"status":0}', $this->getSession()->getPage()->getContent()); $this->assertSame('{"status":0}', $this->getSession()->getPage()->getContent());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment