teewurst/pipeline-bundle

为 teewurst/pipeline 提供的 Symfony 扩展包

1.0.3 2022-04-28 10:38 UTC

This package is auto-updated.

Last update: 2024-09-28 15:44:33 UTC


README

安装

需要安装此包并配置扩展包。

如果你使用 symfony/flex,则无需做任何操作。

composer require teewurst/pipeline-bundle

不使用 symfony/flex 的配置

前往你的 config/bundles.php 文件,并添加以下行

<?php

return [
    ...
    Teewurst\PipelineBundle\PipelineBundle::class => ['all' => true],
];

使用方法

你现在可以使用 pipeline 服务作为递归和复杂管道的工厂。

teewurst\pipeline 中的示例可以表示为

示例 teewurst/pipeline:^2

My\App\MyPipeline:
    factory:   ['@teewurst\pipeline\PipelineService', create]
    arguments:
        # First Argument an array of <TaskInterface|array<TaskInterface|array<...>>>
        $tasks:
            - '@My\App\CheckServiceAvailabilityTask'
            - - '@My\App\ErrorHandlerTask' # catch execution of submission even on error
              - - '@My\App\PrepareDataTask'
                - '@My\App\ValidateDataTask'
                - '@My\App\DoGetOfferRequestTask'
            # .. some additional things like set quote, upload documents etc.
            - - '@My\App\LogResultLocalyTask'
              - '@My\App\LogResultInDWTask'
        # Symfony is not able to handle $options as obejct
        # you need to write a factory itself

示例 teewurst/pipeline:^3

My\App\MyPipeline:
    factory:   ['@teewurst\pipeline\PipelineService', create]
    arguments:
        # First Argument an array of <TaskInterface|array<TaskInterface|array<...>>>
        $tasks:
            - '@My\App\CheckServiceAvailabilityTask'
            - - '@My\App\ErrorHandlerTask' # catch execution of submission even on error
              - - '@My\App\PrepareDataTask'
                - '@My\App\ValidateDataTask'
                - '@My\App\DoGetOfferRequestTask'
             # .. some additional things like set quote, upload documents etc.
            - - '@My\App\LogResultLocalyTask'
              - '@My\App\LogResultInDWTask'
            # Options array to pass pipeline
        $classFqn: My\App\MyPipeline
        $options: # only usable from Pipeline 3.0.0
            - any
            - options