Skip to content

Instantly share code, notes, and snippets.

@silentworks
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silentworks/13d4ad9e3bb2c650e6cb to your computer and use it in GitHub Desktop.
Save silentworks/13d4ad9e3bb2c650e6cb to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
$dispatcher = new EventDispatcher();
$dispatcher->addListener('render', function (Event $event) use ($app) {
$app->render($event['view'], $event['data']);
});
class HelloWorldController {
protected $trigger;
public __construct($dispatcher) {
$this->trigger = $dispatcher;
}
public function hello () {
$this->trigger->dispatch('render', new GenericEvent(
'renderView',
array(
'view' => 'home.twig',
'data' => array('name' => 'world')
)
)
);
}
}
$helloWorld = new HelloWorldController($dispatcher);
$helloWorld->hello();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment