Created
July 20, 2012 03:58
-
-
Save MugeSo/3148548 to your computer and use it in GitHub Desktop.
Render a view without asking.
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 | |
interface HearerInterface | |
{ | |
public function retain($key, $value); | |
} | |
interface SelfExpressableInteface | |
{ | |
public function expressSelf(HearerInteface $hearer); | |
} | |
class Renderer implements HearerInterface | |
{ | |
public function render() | |
{ | |
/* render */ | |
} | |
/* other implementation */ | |
} | |
class SomeModel implements SelfExpressableInterface | |
{ | |
private $_name; | |
public function __construct($name) | |
{ | |
$this->_name = $name; | |
} | |
public function expressSelf(HearerInteface $hearer) | |
{ | |
$hearer->retain('some.identifier.name', $this->_name); | |
} | |
} | |
$renderer = new Renderer(); | |
$model = new SomeModel('hoge'); | |
$model->expressSelf($renderer); | |
$renderer->render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment