Created
August 19, 2010 13:13
-
-
Save JanTvrdik/537838 to your computer and use it in GitHub Desktop.
ReplicatingContainer
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 | |
class FooPresenter extends BasePresenter | |
{ | |
protected function createComponentFooContainer() | |
{ | |
$container = new ReplicatingContainer(); | |
$container->factoryCallback = callback($this, 'editFormFactory'); | |
return $container; | |
} | |
protected function editFormFactory($container, $name) | |
{ | |
return new EditForm($container, $name); | |
} | |
} |
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 | |
/** | |
* Magický, komponenty na požádání tvořící kontejner | |
* | |
* @author Jan Tvrdík | |
*/ | |
class ReplicatingContainer extends Nette\ComponentContainer | |
{ | |
/** @var callback */ | |
public $factoryCallback; | |
/** | |
* Magická továrna na komponenty | |
* | |
* @author Jan Tvrdík | |
* @param string | |
* @return object | |
*/ | |
protected function createComponent($name) | |
{ | |
$callback = $this->factoryCallback; | |
return $callback($this, $name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment