Created
August 21, 2012 11:16
-
-
Save cjsaylor/3414629 to your computer and use it in GitHub Desktop.
Example use of Symbiosis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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()); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[ping] => pong | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment