Problem/Motivation

MenuExportDrushCommands::export() calls MenuExportForm::exportMenus(), which is declared protected. This fatals at runtime when running drush menu_export:export and is flagged by PHPStan at level 0. The Drush
command also calls new MenuExportForm(\Drupal::configFactory()), which is fragile on Drupal 10/11 because ConfigFormBase::__construct now requires a TypedConfigManagerInterface.

Proposed resolution

Extract the export/import logic from MenuExportForm and MenuImportForm into a new service menu_export.menu_exporter (class Drupal\menu_export\MenuExporter) injected with config.factory and entity_type.manager.
Both the forms and the Drush command consume the service.

  • Add src/MenuExporter.php
  • Add menu_export.services.yml and update drush.services.yml
  • Update MenuExportForm/MenuImportForm to delegate to the service
  • Update MenuExportDrushCommands to receive the service via DI
  • Manual test: drush menu_export:export, drush menu_export:import, and the two admin forms
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

foxy-vikvik created an issue. See original summary.

o_timoshchuk’s picture

Assigned: Unassigned » o_timoshchuk

o_timoshchuk’s picture

Assigned: o_timoshchuk » Unassigned
Status: Active » Needs review

The MenuExporter service now encapsulates menu export/import logic, following a refactor of the related forms and Drush commands.