Created
January 14, 2012 15:03
-
-
Save JanTvrdik/1611733 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
public static function renderSnippets($control, $local, $params) | |
{ | |
$control->snippetMode = FALSE; | |
$payload = $control->getPresenter()->getPayload(); | |
if (isset($local->blocks)) { | |
foreach ($local->blocks as $name => $function) { | |
if ($name[0] !== '_' || !$control->isControlInvalid(substr($name, 1))) { | |
continue; | |
} | |
ob_start(); | |
$function = reset($function); | |
$snippets = $function($local, $params); | |
$payload->snippets[$id = $control->getSnippetId(substr($name, 1))] = ob_get_clean(); | |
if ($snippets) { | |
$payload->snippets += $snippets; | |
unset($payload->snippets[$id]); | |
} | |
} | |
} | |
if ($control instanceof Nette\Application\UI\IRenderable) { | |
$queue = array($control); | |
do { | |
foreach (array_shift($queue)->getComponents() as $child) { | |
if ($child instanceof Nette\Application\UI\IRenderable) { | |
if ($child->isControlInvalid()) { | |
$child->snippetMode = TRUE; | |
$child->render(); | |
$child->snippetMode = FALSE; | |
} | |
} else if ($child instanceof Nette\ComponentModel\IContainer) { | |
$queue[] = $child; | |
} | |
} | |
} while ($queue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment