/**
  *
  *
  */
 public function __construct()
 {
     $this->view = new CoreView();
     $this->registry = Registry::getInstance();
     $this->request = $this->registry->request;
     /* Set event object, Event object will be used to attach some data and will be passed to listeners */
     $this->event = new Event();
     // creat event dispatcher object
     $this->eventDispatcher = EventDispatcher::getInstance();
     // set plugin Manager instance
     $this->setPluginManager(PluginManager::getInstance());
     /* */
     $this->setView();
 }
 /**
  *	Add the resource objects which you will be using in the init() method, 
  *	additionally add property for the resource object.
  */
 public function __construct()
 {
     $this->session = \EasyGo\Session\Session::getInstance(new \EasyGo\Session\Handlers\FileHandler());
     $this->eventDispatcher = EventDispatcher::getInstance();
 }
 public function getModuleConfigPath()
 {
     $path = null;
     if (ModuleManager::getInstance()->shouldOverridden($this->getRequest()->getModule()) == true) {
         // if there is no listner attached to the module load event, default behaiour is override the module
         // and load
         if (EventDispatcher::getInstance()->hasListener('before.module.load') == false) {
             return $this->constructPath();
         }
         // Listner is attached to this event, let's trigger the event and check if listener retrun true
         // Override the module
         if (EventDispatcher::getInstance()->trigger('before.module.load', $this->getRequest()->getModule()) == true) {
             return $this->constructPath();
         }
     }
     // if current module is not configured to overridden, simply load module configuration file
     // from app/modules directory
     $module = $this->getRequest()->getModule();
     return $this->getRequest()->getBasePath() . DS . Registry::getInstance('config')->appDir . DS . 'modules' . DS . $module . DS . strtolower($module) . '.xml';
 }
<?php

namespace SiteIndex;

use EasyGo\Event\EventDispatcher;
class SiteIndex
{
    public function myfunc($data)
    {
        $data->name = "shakti";
    }
}
$site = new SiteIndex();
EventDispatcher::getInstance()->attach('after.site.site.index', array($site, 'myfunc'));
Example #5
0
 /**
  *	Set Route according to request
  */
 public function setRoute()
 {
     //Check if the requested module is configured to overriden,  Set the Route to load that overrider module
     $this->matchRoute($this->getRequest()->getRawRoute());
     //check to see if current module is configured to overridden
     if (ModuleManager::getInstance()->shouldOverridden($this->getRequest()->getModule()) == true) {
         // if there is no listner attached to the before.module.load event, default behaiour is override the module
         if (EventDispatcher::getInstance()->hasListener('before.module.load') == false) {
             $this->overrideModule();
             return $this;
         }
         // Listner is attached to this event, let's trigger the event and check if listener retruns true,
         // Override the module
         if (EventDispatcher::getInstance()->trigger('before.module.load', $this->getRequest()->getModule()) == true) {
             $this->overrideModule();
             return $this;
         }
     }
     // Check to see which site this request is for
     // if current module is not configured to overridden, simply load module from app/modules directory
     $namespace = $this->getRequest()->getModule() . '\\Controller';
     $this->class = $this->getRequest()->getCurrentController() . 'Controller';
     $this->route = $namespace . '\\' . $this->class;
     return $this;
 }
 /**
  *	Load Plugins.
  *
  *	
  */
 public function loadPlugins()
 {
     //var_dump($this->plugins);
     foreach ($this->plugins as $pluginName => $class) {
         //echo $pluginName;
         //echo $class;
         // trigger the event before.plugin.load
         // if the listener is attached to this event, trigger the event otherwise
         // simply load the plugin
         if (EventDispatcher::getInstance()->hasListener('before.plugin.load')) {
             if (EventDispatcher::getInstance()->trigger('before.plugin.load', $pluginName) != false) {
                 $this->pluginLoader->loadPlugin($pluginName, $class);
             }
         } else {
             $this->pluginLoader->loadPlugin($pluginName, $class);
         }
     }
 }