Problem/Motivation

As a result of the change of the minimum supported core version to 10.3 in parent issue #3565209: [Meta] Drop support for Drupal 10.2 and below, the minimum supported version of PHP should be 8.1, allowing to implement constants with PHP enum classes: Enumerations.
See how the trend is going with some Drupal core or contrib issues:

Steps to reproduce

Proposed resolution

Impacted files:

1 - Admin Toolbar Search:

  • Constant classes: AdminToolbarSearchConstants
  • Test classes using the constants: AdminToolbarSearchSettingsFormTest, AdminToolbarSearchEventsTest, AdminToolbarSearchTestBase
  • Module file: admin_toolbar_search.module

2 - Admin Toolbar Tools:

  • Constant classes: AdminToolbarToolsConstants
  • Test classes using the constants: AdminToolbarToolsExtraLinksCustomTest, AdminToolbarToolsExtraLinksTest, AdminToolbarToolsEntityCreationTrait

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dydave created an issue. See original summary.

dydave’s picture

Status: Active » Needs review

Quick follow-up on this issue:

All the changes detailed in the issue summary have been implemented and described in the merge request MR !204 above at #2.

Since all the tests and jobs still seem to be passing 🟢, moving issue to Needs review as an attempt to get more testing feedback and reviews.

These changes require Drupal core 10.2 or higher and should probably be merged after related:
#3569351: Drop support for Drupal 10.2 and below

Feel free to let us know if you have any comments, questions or concerns on any aspects of this issue or the suggested changes in the merge request, we would surely be glad to help.
Thanks in advance!

dydave’s picture

Issue summary: View changes

  • dydave committed 309ff1e8 on 3.x
    Issue #3570714 by dydave: Converted the constants classes to enums.
    
dydave’s picture

Status: Needs review » Fixed

Merged, thanks!

The constants classes were converted to enums, following the Drupal core conventions (enums in an Enum namespace, UpperCamelCase cases):

  • Admin Toolbar Search: the AdminToolbarSearchConstants class was removed and replaced with two backed enums in Drupal\admin_toolbar_search\Enum:
    • AdminToolbarSearchHtmlId: the HTML IDs of the search tab, toolbar item, tray and input.
    • AdminToolbarSearchCssClass: the CSS classes of the search field tab and input, used instead of IDs since some themes (Gin) render the toolbar twice.
  • Admin Toolbar Tools (tests): the AdminToolbarToolsConstants class was replaced with two enums in Drupal\Tests\admin_toolbar_tools\Enum:
    • AdminToolbarToolsEntityBundleOperation: the entity bundle operation keys, with a label() method returning the expected link label.
    • AdminToolbarToolsCssClass: the CSS classes used for testing the extra links.
  • The module file and the tests were updated to use the enum cases (AdminToolbarSearchHtmlId::SearchInput->value, AdminToolbarToolsEntityBundleOperation::tryFrom(), etc.), instead of array constants. Some methods of the search JavaScript tests also got return and parameter types.

Note: the final class AdminToolbarSearchConstants was internal, but it is removed from the src folder of Admin Toolbar Search.

All tests pass 🟢 on the tested core versions: 10.3.x, 10.6.x, 11.3.x, 11.4.x and 11.5.x.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.