1. Go to this page and download the library: Download wegnermedia/event-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
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
}
}
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
}
}
$stack = EventManager::stack();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.