Repository navigation
Reference the tasks by a code in the process configurations (task key, #[AsTask]) #91
Copy link
Copy link
Closed
Labels
Description
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:
codeattribute of a newcleverage.tasktag, or new#[AsTask(code: '...')]attribute (autoconfiguration), as for the transformers. - New
taskkey in the task configuration (Configuration), next tooptions. Namedtaskrather thancode: the task list usesuseAttributeAsKey('code'), which re-keys any task containing acodeattribute. servicedeprecated 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 eithertaskorservice.- 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 theTaskRegistrylocator. 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 fromservice. - Documentation: task definition reference (
taskrequired,servicedeprecated), 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).
Reactions are currently unavailable
Activity
[-]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])[/+]#91 - Deprecate the service of the task configurations, documentation…
#91 - Tasks and transformers keep their class name as service id, dep…
#91 - Documentation: unique task codes, no more service aliases
Merge pull request #294 from cleverage/91
#84 - Reference the tasks by their code (task: <code>) in the process…