Skip to content

Instantly share code, notes, and snippets.

@ppeiris
Created October 22, 2013 14:17
Show Gist options
  • Save ppeiris/7101531 to your computer and use it in GitHub Desktop.
Save ppeiris/7101531 to your computer and use it in GitHub Desktop.
<?php
namespace Zsend;
use Zsend\Listener;
use Zend\Mvc\MvcEvent;
class Module
{
public function getAutoloaderConfig()
{
/** Autoloading config */
}
public function getConfig()
{
/** get config code */
}
/**
* Return the service config
*/
public function getServiceConfig() {
return array(
'factories' => array(
/** Add the SendListener class in to the service manager */
'Zsend\Listener\SendListener' => function($servicemanager){
/** return the object of the SendListener class (service manager injected uisng dependency injection) */
return new Listener\SendListener();
},
),
);
}
/**
* Attach the event listeners using EventManager.
*
*/
public function onBootstrap(MvcEvent $event) {
/* get the Event Manager from the application */
$eventManager = $event->getApplication()->getEventManager();
/**
* Have the access to the service manager as follows
* Zsend\Listener\SendListener class implements the ListenerAggregateInterface
*/
$SendListener_Obj = $event->getApplication()->getServiceManager()->get('Zsend\Listener\SendListener')
/** Attach the event */
$eventManager->attach($SendListener_Obj);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment