Last active
August 29, 2015 14:02
-
-
Save silentworks/13d4ad9e3bb2c650e6cb to your computer and use it in GitHub Desktop.
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 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