承接 bpartner/tasks 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bpartner/tasks

Composer 安装命令:

composer require bpartner/tasks

包简介

Make callable task easy

README 文档

README

Latest Version on Packagist Total Downloads

Use this trait for easy call your task

Installation

You can install the package via composer:

composer require bpartner/tasks

Usage

Create task

namespace App\Test;

use Bpartner\Tasks\Tasks;

class Task extends Tasks
{
     /**
     * @param \Illuminate\Support\Fluent $object        #for Laravel
     *
     * @return mixed
     */
    public function __invoke($object)
    {
        // TODO: Implement __invoke() method.
    }
}

Use Task with CallableTrait in any class

use Illuminate\Support\Fluent;
use Illuminate\Http\Request;

class Controller
{
    use CallableTrait;

    public function index(Request $request)
    {
        $data = new Fluent($request->all());

        return $this->run(\App\Test\Tasks::class, $data); 
    }
}

Run pipeline from tasks

To start the sequence of your tasks, you must first add a trait use PipelineTaskTrait; to all tasks.

Implement handle method in task.

Anywhere in the code where the CallableTrait is used, you need to create an array from the sequence of tasks,

and call $this->runPipe($data, $pipes); method.

namespace App\Test;

use Bpartner\Tasks\Tasks;
use Bpartner\Tasks\PipelineTaskTrait;

class Task extends Tasks
{
    use PipelineTaskTrait;

     /**
     * @param \Illuminate\Support\Fluent $object 
     *
     * @return mixed
     */
    public function __invoke($object)
    {
        // TODO: Implement __invoke() method.
    }

    /**
     * @param \Illuminate\Support\Fluent $content
     * @param \Closure                   $next
     *
     * @return mixed
     */
    public function handle(Fluent $content, Closure $next): Fluent
    {
        //Check or modify $content

        return $next($content);
    }

}

//----------------------------------------------

use Illuminate\Support\Fluent;
use Illuminate\Http\Request;

class Controller
{
    use CallableTrait;

    public function index(Request $request)
    {
        $data = new Fluent($request->all());
        $pipes = [
            \App\Test\Task::class,
            \App\Test\Task2::class
        ];

        return $this->runPipe($data, $pipes); 
    }
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固