Make it possible for projects to be sorted in an arbitrary order

Created on 1 March 2025, about 1 month ago

Problem/Motivation

It's likely that Drupal CMS will want to expose miniature project browsers that display small, curated lists of projects from various sources.

It's already possible to choose which projects to display by tailoring the queries (i.e., ProjectBrowserSourceInterface::getProjects($query)) precisely, but it's not possible to control the order in which those projects appear. But that's an important part of curation, and will almost certainly be asked for.

Proposed resolution

Create an API that allow individual sources to return their projects in an arbitrary order defined in the plugin configuration.

This should take the form of a trait that sources can use if they want to. The trait will provide one method: sortByDefinedOrder($projects, $order). $order is an array of unqualified project IDs. The sorting algorithm will automatically move any projects listed in $order to the top of the list, and then sort those to match what's in $order.

Exactly how the sources receive this configuration is out of scope for this issue. Suffice it to say that, if there is a configured order, sources can take advantage of this new trait to ensure that order is respected.

Feature request
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