Exemple #1
0
 public function testPluginContext()
 {
     $manager = new PluginManager('', '');
     $testPlugin = $this->getMock('Zumba\\Symbiosis\\Test\\Plugin\\MockablePlugin', ['mockMe']);
     $testPlugin->expects($this->once())->method('mockMe');
     $manager->initializePlugin($testPlugin);
     $event = new Event('test', ['val' => true]);
     $event->setPluginContext($manager)->trigger();
 }
 public function testEventSpawner()
 {
     $pluginManager = new PluginManager('', '');
     $testPlugin = $this->getMock('Zumba\\Symbiosis\\Test\\Plugin\\MockablePlugin', ['mockMe']);
     $testPlugin->expects($this->once())->method('mockMe');
     $pluginManager->initializePlugin($testPlugin);
     $event = $pluginManager->spawnEvent('test', ['var' => 1]);
     $this->assertInstanceOf('Zumba\\Symbiosis\\Event\\Event', $event);
     $this->assertEquals(['var' => 1], $event->data());
     $event->trigger();
 }
Exemple #3
0
 /**
  * Convenience method for triggering the event from the event object.
  *
  * @param  Zumba\Symbiosis\EventRegistry $registry Single registry instance if used outside of global context.
  * @return boolean
  */
 public function trigger(EventRegistry $registry = null)
 {
     if ($this->pluginContext) {
         return $this->pluginContext->trigger($this);
     }
     return $registry instanceof EventRegistry ? $registry->trigger($this) : EventManager::trigger($this);
 }
<?php

use Zumba\Symbiosis\Plugin\PluginManager;
// Somewhere in your application bootstrap, load your plugins
PluginManager::loadPlugins('/path/to/your/plugin/directory', 'YourApp\\Plugin');