jacksunny / eventprocess

该包最新版本(v1.0)没有可用的许可证信息。

laravel 框架的简单事件处理插件,包括树形派发

v1.0 2017-08-08 03:35 UTC

This package is not auto-updated.

Last update: 2024-09-29 03:31:14 UTC


README

laravel 框架的简单事件处理插件,包括树形派发

如何安装和配置包

  1. 安装laravel包 composer require "jacksunny/eventprocess":"dev-master"

如果失败,请检查 composer.json 文件中是否存在 "minimum-stability": "dev" 行

  1. 在 app.config 文件 providers 部分后追加新的服务提供者文件行,它应该看起来像
   'providers' => [
        Illuminate\Auth\AuthServiceProvider::class,
        ......
        Jacksunny\EventProcess\EventProcessServiceProvider::class,
    ],
   
  1. 创建事件类 TestEvent

    class TestEvent extends BaseEvent implements EventContract {
    
    public $context_obj;
    
    public function __construct(User $user, Request $request, $entity, $action_name, array $options = null, TreeWalkerContract $tree_walker = null) {
        parent::__construct($tree_walker, $user, $request, $entity, $action_name, $options);
        $this->context_obj = $user;
    }
    
  2. 创建事件监听器类 TestEventListener

    class TestEventListener extends BaseEventListener implements EventListenerContract {
    
    public function __construct() {
        parent::__construct($this);
    }
    
    public function handle(TestEvent $event) {
        parent::handle($event);
    
        //other process code on this event type
    }
    
  3. 如果您在使用过程中遇到任何问题或错误,请通知我,谢谢!