定制 nathansalter/decision-pipeline 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nathansalter/decision-pipeline

Composer 安装命令:

composer require nathansalter/decision-pipeline

包简介

Simple Middleware-type method of making decisions

README 文档

README

Middleware-esque way of making decisions instead of using Event Managers

Usage

Usage of this is very simple. Providing the pipeline a question object, to decide on will pass this question through to all of the decision actors (deciders). Each decider in turn chooses to either make an ultimate decision or make a decision which may be overridden at a later stage.

Example

Preferable usage is to create your own Question and Decision classes, but if using PHP7 then you MAY use anonymous classes. Deciders passed into the Pipeline MUST either implement PipelineDecider or be a closure.

$pipeline = new DecisionPipeline([
    function (Question $question, Decision $decision, callable $next = null) {
        if($question->cannot()) {
            throw new \RuntimeException('I cannot!');
        }
        return $next($question, $decision);
    },
    new SpecialDecider()
]);
$decision = $pipeline->decide(new SpecialQuestion());

If no decision is made, the NoDecision class will be returned. You MAY return a custom default decision by simply passing it in as the second parameter to the constructor.

$pipeline = new DecisionPipeline([], new SpecialDefaultDecision());

Each decider is ALWAYS run in order that it is passed into the constructor, so any priority MUST be set in the constructor.

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固