trash-panda/m2-callable-event-listeners 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

trash-panda/m2-callable-event-listeners

Composer 安装命令:

composer require trash-panda/m2-callable-event-listeners

包简介

Listen to events with plain PHP callable minus any configuration

README 文档

README

Allow to register event listeners with a plain PHP callable - minus the config.

Installation

$ composer require trash-panda/m2-callable-event-listeners
$ php bin/magento setup:upgrade

Usage

Grab an instance of \TrashPanda\CallableEventListeners\Model\Manager either via DI or from the object manager and pass an event name and a callable to the listen method.

use TrashPanda\CallableEventListeners\Model\Manager;
use Magento\Framework\Event\Observer;

class MyCommand
{
    public function ___construct(Manager $manager)
    {
        $manager->listen('some-event', function (Observer $observer) {
            echo "Hey!\n\n";
            var_dump($observer->getData());
        });
    }
}

Now when the event some-event is dispatched from \Magento\Framework\Event\Manager your callable will be invoked along with any other listeners attached via config.

Use Cases

  • Scoping events to one particular code path - eg a command or a cron
  • Prototyping
  • Improved feedback from IDE - regarding classes and method existence

统计信息

  • 总下载量: 1.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固