Skip to content

Reference the tasks by a code in the process configurations (task key, #[AsTask]) #91

Closed

Description

@johnkrovitch

Description

A task of a process configuration references its service with its full class name (or service id):

transform:
    service: '@CleverAge\ProcessBundle\Task\TransformerTask'

which is long, error-prone, and requires remembering the namespaces of every task (bundle, bridges, application). The transformers are already referenced by a short code (transformers: { trim: ~ }), and since #276 (PR #293) their code is declared on the service (code attribute of the cleverage.transformer tag, #[AsTransformer]). Apply the same logic to the tasks:

transform:
    task: transformer
    options:
        transformers: { trim: ~ }

Design

  • Code of a task service: code attribute of a new cleverage.task tag, or new #[AsTask(code: '...')] attribute (autoconfiguration), as for the transformers.
  • New task key in the task configuration (Configuration), next to options. Named task rather than code: the task list uses useAttributeAsKey('code'), which re-keys any task containing a code attribute.
  • service deprecated since 5.4 (configuration deprecation, only for the tasks that set it), removed in v6.0 (v6.0: remove the deprecated code #292): a task defines either task or service.
  • Resolution at compile time: TaskLocatorCompilerPass (Fetch tasks from a service locator instead of the service container (v5 step of #114) #275) maps the code to the tagged service and puts it in the TaskRegistry locator. An unknown code fails the container compilation (with the list of the known codes), as well as a code declared twice.
  • Codes of the bundle tasks: the 58 tasks get the snake case of their class name without Task: transformer, constant_output, csv_reader, input_iterator, file_writer… (a test checks they are all set and unique). The tasks and transformers keep their class name as service id; fetching them directly from the service container is deprecated since 5.4 (container.private), they will be private in v6.0 (v6.0: remove the deprecated code #292).
  • Codes of the bridge bundles: prefixed by the bridge name (<bridge>_), to avoid collisions: archive_unzip, cache_get, doctrine_reader, flysystem_file_fetch, rest_request, soap_request… (one issue per bridge, requiring the process-bundle version shipping the tag), needed before releasing 5.4 so that the users of the bridges can migrate from service.
  • Documentation: task definition reference (task required, service deprecated), custom tasks (#[AsTask]), the code on the reference page of each task (* **Code**: transformer``), all the examples switched to the codes; the demo project to migrate.

Requirements

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

Breaking changes

None until v6.0: service keeps working (deprecated), as the direct access to the task and transformer services from the container (deprecated).

Activity

  1. added this to the v3.1 milestone on Dec 2, 2019
  2. modified the milestones: v3.1.0, v3.1.1 on Feb 12, 2020
  3. modified the milestones: v3.1.1, on Sep 17, 2021
  4. removed this from the milestone on Oct 16, 2023
  5. added this to the v5.0 milestone on Dec 16, 2024
  6. modified the milestones: v5.0, v6.0 on Dec 9, 2025
  7. removed this from the v6.0 milestone on Oct 14, 2026
  8. changed the title [-]Allow using codes for tasks and transformers, to avoid remembering all tasks needed[/-] [+]Reference the tasks by a code in the process configurations (task key, #[AsTask])[/+] on Oct 14, 2026
  9. added 4 commits that reference this issue on Oct 15, 2026
  10. added a commit that references this issue on Oct 20, 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