wegnermedia/event-manager

Simple Event Manager Tool for Laravel
16 2
Install
composer require wegnermedia/event-manager
Latest Version:1.0.0
PHP:>=5.4.0
Last Updated:Jul 21, 2014
Links: GitHub  ·  Packagist
Maintainer: wegnermedia

Laravel Event Manager Service

This Package gives you an easy way to raise and dispatch events.

Installation

Per usual, install Commander through Composer.

"require": {
    "wegnermedia/event-manager": "dev-master"
}

Next, add the facade app/config/app.php.

'aliases' => [
    'EventManager' => 'Wegnermedia\EventManager\Facade'
]

And now build something awesome.

Usage

app/controllers/CartController.php

<?php

class CartController extends ShopController {

	/**
	 * Add Item to Cart.
	 *
	 * @return Response
	 */
	public function addItem()
	{
		$inputs = Input::all();

		// Validation goes here ...

		$command = new AddItemToCartCommand($inputs);

		$result = Commander::execute($command);

		EventManager::dispatch();

		// ... create the Response
	}
}

app/Shop/Cart/AddItemToCartCommandHandler.php

<?php

use Wegnermedia\Commander\CommandHandlerInterface;

class AddItemToCartCommandHandler implements CommandHandlerInterface {

	/**
	 * Handle the command
	 *
	 * @return mixed
	 */
	public function handle($command)
	{
		// some awesome stuff ...

		// Raise and event with the Namespace of "Shop"
		// Event::listen('whenShop*', ... );
		EventManager::raise( new AddingItemToCartWasSuccessfulEvent($cart, $item), 'Shop' )

		// ... create the Response
	}
}

Sometimes you may want to look into the stack

	$stack = EventManager::stack();

Done!

Related Packages

wegnermedia/eventer

Easy Event Management

16 0
andhikamaheva/date

A date library to help you work with dates in different languages

13 1
vlados/laravel-blade-crawler-detect

Boost Lighthouse and PageSpeed scores by hiding cookie banners, chat widgets and...

5,132 0
maystro/filament-popup-modal

A comprehensive modal dialog system for FilamentPHP with progress bars, callback...

7 1