Skip to content

#275 - Fetch tasks from a service locator instead of the service container - #290

Merged
njoubert-cleverage merged 2 commits into
mainfrom
275
Oct 14, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
275

Conversation

@njoubert-cleverage

@njoubert-cleverage njoubert-cleverage commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #275, closes #114: the tasks are fetched from a service locator built at compile time from the process configurations, instead of the whole service container (@service_container + $container->get(), duplicated in ProcessManager and ProcessHelpCommand with a @todo).

Changes

  • TaskRegistry (cleverage_process.registry.task, FQCN alias): getTask(TaskConfiguration): TaskInterface, the code previously duplicated in ProcessManager::initialize() and ProcessHelpCommand::getTaskService() (leading @ optional, TaskInterface check, same error messages).
  • TaskLocatorCompilerPass (internal): collects the service of every task of clever_age_process.configurations (first argument of the process configuration registry) and registers a ServiceLocator of exactly these services (ServiceLocatorTagPass::register()). Unknown ids are left out and keep failing at runtime with the same message. Consequences:
    • a task service can be private (checked with a compiled container: a private application task runs);
    • non-shared tasks stay non-shared (ServiceLocator::get() calls the factory each time; checked: two getTask() calls give two instances).
  • ProcessManager and ProcessHelpCommand: new optional last constructor argument ?TaskRegistry $taskRegistry = null (the $container argument is kept), injected in manager.yaml / command.yaml. Without it (subclass or custom definition): Since cleverage/process-bundle 5.4: Not passing a "…\TaskRegistry" to "…::__construct()" is deprecated: the tasks are fetched from the service container. The argument will be required in v6.0., and the tasks are fetched from the container exactly as before.
  • Fallback for services not in the locator (e.g. a configuration added at runtime by a ProcessConfigurationRegistry subclass): TaskRegistry gets the service from the service container with Since cleverage/process-bundle 5.4: Fetching the service "…" of the task "…" from the service container is deprecated: it is not referenced by the process configurations known when the container is compiled. It will not be found anymore in v6.0. An unknown service referenced with @ still throws the container ServiceNotFoundException, as before.
  • Docs: public is no longer presented as required for the task services (quick start, custom tasks, common setup, good practices).
  • CHANGELOG (Latest). Deprecation version 5.4, as decided.

#114 ("Tasks services should not be public") is handled: task services no longer need to be public. Left for v6.0, with the other deprecated code: remove the $container arguments and both fallbacks (the task services of the bundle and of the bridges can then be made private).

Checks

  • Minimal compiled kernel (FrameworkBundle + MonologBundle + this bundle): bundle task via the locator, private application task OK, non-shared task gives distinct instances, no process-bundle deprecation in normal use, fallback deprecation for a non-referenced service.
  • Demo project (main of process-bundle with this change copied in vendor/, then reverted): lint:container OK, cleverage:process:help, demo.transformer and demo.archive.zip (bridge task referenced by its public FQCN alias) executed, cleverage_process.registry.task gets Service(.service_locator.*).
  • Tests: TaskRegistryTest (locator, @ optional, new instance per call, deprecated fallback, unknown service with / without @, without fallback, not a TaskInterface), TaskLocatorCompilerPassTest (referenced services incl. a private one, unknown left out, no registry), ProcessManagerTaskRegistryTest (with registry: no deprecation; without: deprecation, process still runs), ProcessHelpCommandTest (deprecation without registry). Existing ProcessManager*Test now pass a TaskRegistry.
  • After composer update (PHP 8.5): 929 tests OK, PHPStan, PHP-CS-Fixer, Rector OK. Lowest dependencies (PHP 8.2, Symfony 6.4.0): 929 tests OK.

Requirements

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

Breaking changes

None: same constructor signatures plus an optional last argument, same behaviour without it (deprecated), tasks stay public. Deprecations only on the fallback paths. Minor: a task service referenced by a process configuration is now built through the locator (same definition, same shared setting).

🤖 Generated with Claude Code

…ainer

- New TaskRegistry (cleverage_process.registry.task, FQCN alias): resolves the
  service of a task configuration (with or without "@"), code previously
  duplicated in ProcessManager and ProcessHelpCommand.
- New internal TaskLocatorCompilerPass: builds the registry service locator
  from the services referenced by the process configurations (known at
  compile time); unknown services keep failing at runtime as before. Private
  task services work; non-shared ones stay non-shared.
- ProcessManager and ProcessHelpCommand: new optional last constructor
  argument ?TaskRegistry; not passing it is deprecated (since 5.4), the tasks
  are then fetched from the container as before.
- TaskRegistry falls back on the service container, with a deprecation (since
  5.4), for a service not referenced by the process configurations.
- Both fallbacks will be removed in v6.0 (#114). Documentation and tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… longer need to be public

- Task definition reference: the `service` of a task is a service id or alias,
  with or without a leading `@` (the 4 equivalent forms, with the archive
  bridge UnzipTask as example), behaviour with an unknown service; services
  and aliases referenced by the process configurations can be private.
- Quick start, custom tasks, common setup, good practices: `public: true` is
  no longer presented as required for the task services (only kept by
  autoconfiguration for the deprecated fallback on the service container).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit dcee969 into main Oct 14, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fetch tasks from a service locator instead of the service container (v5 step of #114) Tasks services should not be public

1 participant