Skip to content

Fetch tasks from a service locator instead of the service container (v5 step of #114) #275

Closed

Description

@njoubert-cleverage

Description

Tasks are fetched from the whole service container: ProcessManager::initialize() and ProcessHelpCommand::getTaskService() receive @service_container and call $container->get() on the service of each task (duplicated code, with a @todo pointing to service locators in both places).

Consequences:

  • every task service must be public (public: true on all bundle tasks, public FQCN aliases in the bridge bundles, _instanceof blocks in applications): this is Tasks services should not be public #114, planned for v6.0;
  • injecting service_container is discouraged in bundles;
  • a typo in a task service is only detected when the process runs.

This ticket is the v5 preparation step of #114, without breaking change.

Proposed fix

The process configurations are known at compile time (clever_age_process.configurations, first argument of cleverage_process.registry.process_configuration), so the referenced services are known too:

  1. A compiler pass collects the service of every task (with or without the @ prefix) and builds a ServiceLocator containing exactly these services (only ids that exist; unknown ids keep failing at runtime with the current message). Non-shared tasks stay non-shared (ServiceLocator::get() calls the factory each time).
  2. A small TaskRegistry (cleverage_process.registry.task, getTask(TaskConfiguration): TaskInterface) wraps the locator and holds the code currently duplicated in ProcessManager and ProcessHelpCommand (@ prefix, TaskInterface check, error messages).
  3. ProcessManager and ProcessHelpCommand get this registry as a new optional constructor argument (added last, the $container argument is kept). When it is not provided (subclass or custom definition), they fall back to the container and trigger a deprecation.
  4. If a service is not in the locator but exists in the container (e.g. configuration added at runtime by a ProcessConfigurationRegistry subclass), fall back to the container with a deprecation.

Follow-up in v6.0 (#114): remove the container argument and the fallbacks, make bundle tasks private, make the FQCN aliases of the bridge bundle tasks private.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None: same constructor signatures (new optional last argument), tasks stay public, same runtime errors. Deprecations only on the fallback paths.

Activity

  1. added 2 commits that reference this issue on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions