cjsaylor
8/21/2012 - 11:16 AM

Example use of Symbiosis

Example use of Symbiosis

Array
(
    [ping] => pong
)
<?php

use \Zumba\Symbiosis\Event\Event;

// Somewhere in your app, trigger plugins listening to event
$event = new Event('sample.someevent', array('ping' => 'pong'));
$event->trigger();
<?php

namespace \YourApp\Plugin;

use \Zumba\Symbiosis\Framework\Plugin,
    \Zumba\Symbiosis\Event\EventManager;

class SamplePlugin extends Plugin {

  public function registerEvents() {
    EventManager::register('sample.someevent', function($event) {
      print_r($event->data());
    });
  }

}
<?php

use \Zumba\Symbiosis\Plugin\PluginManager;

// Somewhere in your application bootstrap, load your plugins
PluginManager::loadPlugins(
    '/path/to/your/plugin/directory', // Path to where you stored your plugins
    'YourApp\Plugin'                  // namespace defined in your plugins (see example above)
);