Replace InstallerController's tempstore with a centralized InstallState service

Created on 7 October 2024, 3 months ago

Problem/Motivation

In order to make the "put a bunch of projects in your cart and check out" UX work, we need to have a more central way for Svelte to be aware of which projects are being added to the site, and how far along they are. Right now, the closest thing we have is a kludgey, awkward use of the shared tempstore, mediated by InstallerController.

Proposed resolution

Create a new service, called Drupal\project_browser\InstallState, defined dynamically by the ProjectBrowserServiceProvider if Package Manager is installed.

InstallState needs a method called toArray() (or similar), which dumps a structure like this:

[
  "project_id1": [
    "source": "source_plugin_id",
    "status": "requiring"
  ],
  "project_id2": [
    // same idea
  ],
]

The status field can be one of three things: requiring, activating, or installed. It can be changed per-project by a public method like InstallState::setState(Project $project, ?string $status) (if $status is NULL, the project's install state is deleted). Internally, InstallState should use the project_browser tempstore, and it should also have a getState(Project $project): ?string method, for introspection purposes.

When the activation is complete, all the projects should have their status cleared (setStatus($project, NULL)).

Let's make InstallerController use this service, and remove setRequiringState(). We shouldn't need much, if any, explicit test coverage here because the controller already has robust functional test coverage.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024