コード例 #1
0
 public function setUp()
 {
     parent::setUp();
     CroogoPlugin::unload('Example');
     CroogoPlugin::load('Shops');
     CroogoEventManager::loadListeners();
     $request = $this->getMock('CakeRequest');
     $response = $this->getMock('CakeResponse');
     $this->Users = new TestUsersEventController($request, $response);
     $this->Nodes = new TestNodesEventController($request, $response);
 }
コード例 #2
0
 /**
  * Test Reuse the same Event Listener class
  */
 public function testAliasingEventListener()
 {
     $eventManager = CroogoEventManager::instance();
     $listeners = $eventManager->listeners('Controller.Nodes.afterAdd');
     foreach ($listeners as $listener) {
         $eventManager->detach($listener['callable']);
     }
     $handlers = array('Shops.ShopsNodesEventHandler', 'CustomShopsNodesEventHandler' => array('options' => array('className' => 'Shops.ShopsNodesEventHandler')));
     Configure::write('EventHandlers', $handlers);
     Cache::delete('EventHandlers', 'cached_settings');
     CroogoEventManager::loadListeners();
     $listeners = $eventManager->listeners('Controller.Nodes.afterAdd');
     foreach ($listeners as $listener) {
         $this->assertInstanceOf('ShopsNodesEventHandler', $listener['callable'][0]);
     }
 }
コード例 #3
0
if ($theme = Configure::read('Site.theme')) {
    App::build(array('View/Helper' => array(App::themePath($theme) . 'Helper' . DS)));
}
/**
 * List of core plugins
 */
Configure::write('Core.corePlugins', array('Settings', 'Acl', 'Blocks', 'Comments', 'Contacts', 'Menus', 'Meta', 'Nodes', 'Taxonomy', 'Users'));
/**
 * Plugins
 */
$aclPlugin = Configure::read('Site.acl_plugin');
$pluginBootstraps = Configure::read('Hook.bootstraps');
$plugins = array_filter(explode(',', $pluginBootstraps));
if (!in_array($aclPlugin, $plugins)) {
    $plugins = Hash::merge((array) $aclPlugin, $plugins);
}
foreach ($plugins as $plugin) {
    $pluginName = Inflector::camelize($plugin);
    if (!file_exists(APP . 'Plugin' . DS . $pluginName)) {
        CakeLog::write(LOG_ERR, 'Plugin not found during bootstrap: ' . $pluginName);
        continue;
    }
    $bootstrapFile = APP . 'Plugin' . DS . $pluginName . DS . 'Config' . DS . 'bootstrap.php';
    $bootstrap = file_exists($bootstrapFile);
    $routesFile = APP . 'Plugin' . DS . $pluginName . DS . 'Config' . DS . 'routes.php';
    $routes = file_exists($routesFile);
    $option = array($pluginName => array('bootstrap' => $bootstrap, 'routes' => $routes));
    CroogoPlugin::load($option);
}
CroogoEventManager::loadListeners();