phmlabs/annovent 问题修复 & 功能扩展

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

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

phmlabs/annovent

最新稳定版本:1.0.1

Composer 安装命令:

composer require phmlabs/annovent

包简介

Simple lightweight event dispatcher using annotations for registering listeners

README 文档

README

#Annovent

Annovent is a simple to use event dispatcher inspired by the symfony component event dispatching implementation. It tries to provide all the features symfony does with some useful extensions.

##Simple Usage

The Annovent dispatcher can be used in a simple and standard way as you are used from symfony:

$dispatcher = new Dispatcher();
$dispatcher->connect('SomeComponent.Render', array($listener, 'Method1'));
$dispatcher->notify(new Event('SomeComponent.Render', array('foo' => 'bar'));

##Namespace

An extra feature of this event dispatcher is the so called namespacing. It is possible to register a lister to a complete set events belonging to a special namespace.

$dispatcher->connect('SomeComponent.*', array($listener, 'Method1'));
$dispatcher->connect('*', array($listener, 'Method2'));

The first listener will be notified whenever a event is fired that starts with SomeComponent. The second one will always be notified.

##Annotation

Connection a listener to a special event is not limited to the connect method. It is also possible to register a listener using annotation (see doctrine common).

class Listener
{
  /**
   * @Event("SomeComponent.Render")
   */
  public function method1(Event $event)
  {
  }
}

$dispatcher->connectListener( new Listener );

Using the connectListener method it is possible to connect a bunch of callbacks at once.

##Named Parameters

If desired the event dispatcher can be used with named parameters.

class Listener2
{
  /**
   * @Event("SomeComponent.Render")
   */
  public function method1($argument1, $foo)
  {
  }
}
$dispatcher->notify(new Event('SomeComponent.Render', array('foo' => 'bar', 'argument1' => 'arg1' ));

统计信息

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

GitHub 信息

  • Stars: 11
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-03