public function addSnippet($name, $content) { if ($this->payload === NULL) { $this->payload = $this->control->getPresenter()->getPayload(); } $this->payload->snippets[$this->control->getSnippetId($name)] = $content; }
public static function renderSnippets(UI\Control $control, \stdClass $local, array $params) { $control->snippetMode = FALSE; $payload = $control->getPresenter()->getPayload(); if (isset($local->blocks)) { foreach ($local->blocks as $name => $function) { if ($name[0] !== '_' || !$control->isControlInvalid((string) substr($name, 1))) { continue; } ob_start(function () { }); $function = reset($function); $snippets = $function($local, $params + array('_snippetMode' => TRUE)); $payload->snippets[$id = $control->getSnippetId((string) substr($name, 1))] = ob_get_clean(); if ($snippets !== NULL) { // pass FALSE from snippetArea if ($snippets) { $payload->snippets += $snippets; } unset($payload->snippets[$id]); } } } $control->snippetMode = TRUE; if ($control instanceof UI\IRenderable) { $queue = array($control); do { foreach (array_shift($queue)->getComponents() as $child) { if ($child instanceof UI\IRenderable) { if ($child->isControlInvalid()) { $child->snippetMode = TRUE; $child->render(); $child->snippetMode = FALSE; } } elseif ($child instanceof Nette\ComponentModel\IContainer) { $queue[] = $child; } } } while ($queue); } }
public function getSnippetId($name = NULL) { return $this->control->getSnippetId($name); }
public static function renderSnippets(Nette\Application\UI\Control $control, \stdClass $local, array $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]); } } } $control->snippetMode = true; 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; } } elseif ($child instanceof Nette\ComponentModel\IContainer) { $queue[] = $child; } } } while ($queue); } }
public function getSnippetId($name = NULL) : string { $uniqueId = $this->getUniqueId(); return str_replace($uniqueId, implode('-', [$uniqueId, isset($this->views[$name]) ? $name : $this->view]), parent::getSnippetId(isset($this->views[$name]) ? NULL : $name)); }
Nette\InvalidStateException("Cannot include undefined parent block '$name'.");}$block($context,$params);}static function renderSnippets(Nette\Application\UI\Control$control,\stdClass$local,array$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;}}elseif($child instanceof Nette\ComponentModel\IContainer){$queue[]=$child;}}}while($queue);}}}}namespace Nette\Utils{use
/** * Custom snippet format */ public function getSnippetId($name = NULL) { if ($this->snippetGenerator === NULL) { return parent::getSnippetId($name); } return $this->snippetGenerator->getSnippetId($this, $name); }