2017 © Pedro Peláez
 

library event-manager

Simple Event Manager Tool for Laravel

image

wegnermedia/event-manager

Simple Event Manager Tool for Laravel

  • Monday, July 21, 2014
  • by wegnermedia
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel Event Manager Service

This Package gives you an easy way to raise and dispatch events., (*1)

Installation

Per usual, install Commander through Composer., (*2)

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

Next, add the facade app/config/app.php., (*3)

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

And now build something awesome., (*4)

Usage

app/controllers/CartController.php, (*5)

<?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, (*6)

<?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!, (*7)

The Versions

21/07 2014

dev-master

9999999-dev

Simple Event Manager Tool for Laravel

  Sources   Download

The Requires

 

by Stefan Wegner

laravel eventing

21/07 2014

1.0.0

1.0.0.0

Simple Event Manager Tool for Laravel

  Sources   Download

The Requires

 

by Stefan Wegner

laravel eventing