本文整理汇总了PHP中Nette\Application\UI\Control::getPresenter方法的典型用法代码示例。如果您正苦于以下问题:PHP Control::getPresenter方法的具体用法?PHP Control::getPresenter怎么用?PHP Control::getPresenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Control
的用法示例。
在下文中一共展示了Control::getPresenter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSnippet
public function addSnippet($name, $content)
{
if ($this->payload === NULL) {
$this->payload = $this->control->getPresenter()->getPayload();
}
$this->payload->snippets[$this->control->getSnippetId($name)] = $content;
}
示例2: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param ItemInterface $item
*
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
if ($item->getExtra('link', false) && $this->parentControl) {
$presenter = $this->parentControl->getPresenter(true);
$item->setCurrent(call_user_func_array(array($presenter, 'isLinkCurrent'), $item->getExtra('link')));
return $item->isCurrent();
}
return null;
}
示例3: createTemplate
/**
* @return Template
*/
public function createTemplate(UI\Control $control = NULL)
{
$latte = $this->latteFactory->create();
$template = new Template($latte);
$presenter = $control ? $control->getPresenter(FALSE) : NULL;
if ($control instanceof UI\Presenter) {
$latte->setLoader(new Loader($control));
}
if ($latte->onCompile instanceof \Traversable) {
$latte->onCompile = iterator_to_array($latte->onCompile);
}
array_unshift($latte->onCompile, function ($latte) use($control, $template) {
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
UIMacros::install($latte->getCompiler());
if (class_exists(Nette\Bridges\FormsLatte\FormMacros::class)) {
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
}
if ($control) {
$control->templatePrepareFilters($template);
}
});
$latte->addFilter('url', 'rawurlencode');
// back compatiblity
foreach (['normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse'] as $name) {
$latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
}
$latte->addFilter('null', function () {
});
$latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
// intentionally ==
});
if (!isset($latte->getFilters()['translate'])) {
$latte->addFilter('translate', function (Latte\Runtime\FilterInfo $fi) {
throw new Nette\InvalidStateException('Translator has not been set. Set translator using $template->setTranslator().');
});
}
// default parameters
$template->user = $this->user;
$template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
$template->flashes = [];
if ($control) {
$template->control = $control;
$template->presenter = $presenter;
$latte->addProvider('uiControl', $control);
$latte->addProvider('uiPresenter', $presenter);
$latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($control));
}
$latte->addProvider('cacheStorage', $this->cacheStorage);
// back compatibility
$template->_control = $control;
$template->_presenter = $presenter;
$template->netteCacheStorage = $this->cacheStorage;
if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
$id = $control->getParameterId('flash');
$template->flashes = (array) $presenter->getFlashSession()->{$id};
}
return $template;
}
示例4: getUri
/**
* @param \Knp\Menu\ItemInterface $item
* @param array $options
* @return null|string
*/
protected function getUri(ItemInterface $item, array $options)
{
if ($item->getUri()) {
return $item->getUri();
} elseif ($item->getExtra('link', false) && $this->parentControl) {
$presenter = $this->parentControl->getPresenter(true);
return call_user_func_array(array($presenter, 'link'), $item->getExtra('link'));
}
return null;
}
示例5: createTemplate
/**
* @return Template
*/
public function createTemplate(UI\Control $control)
{
$latte = $this->latteFactory->create();
$template = new Template($latte);
$presenter = $control->getPresenter(FALSE);
if ($control instanceof UI\Presenter) {
$latte->setLoader(new Loader($control));
}
if ($latte->onCompile instanceof \Traversable) {
$latte->onCompile = iterator_to_array($latte->onCompile);
}
array_unshift($latte->onCompile, function ($latte) use ($control, $template) {
$latte->getParser()->shortNoEscape = TRUE;
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
UIMacros::install($latte->getCompiler());
if (class_exists('Nette\Bridges\FormsLatte\FormMacros')) {
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
}
$control->templatePrepareFilters($template);
});
$latte->addFilter('url', 'rawurlencode'); // back compatiblity
foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
$latte->addFilter($name, 'Nette\Utils\Strings::' . $name);
}
$latte->addFilter('null', function () {});
$latte->addFilter('length', function ($var) {
return is_string($var) ? Nette\Utils\Strings::length($var) : count($var);
});
$latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally ==
});
// default parameters
$template->control = $template->_control = $control;
$template->presenter = $template->_presenter = $presenter;
$template->user = $this->user;
$template->netteHttpResponse = $this->httpResponse;
$template->netteCacheStorage = $this->cacheStorage;
$template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
$template->flashes = array();
if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
$id = $control->getParameterId('flash');
$template->flashes = (array) $presenter->getFlashSession()->$id;
}
return $template;
}
示例6: renderSnippets
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);
}
}
示例7: createTemplate
/**
* @return Template
*/
public function createTemplate(UI\Control $control)
{
$latte = $this->latteFactory->create();
$template = new Template($latte);
$presenter = $control->getPresenter(FALSE);
if ($control instanceof UI\Presenter) {
$latte->setLoader(new Loader($control));
}
if ($latte->onCompile instanceof \Traversable) {
$latte->onCompile = iterator_to_array($latte->onCompile);
}
array_unshift($latte->onCompile, function ($latte) use($control, $template) {
$latte->getParser()->shortNoEscape = TRUE;
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
UIMacros::install($latte->getCompiler());
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
$control->templatePrepareFilters($template);
});
$latte->addFilter('url', 'rawurlencode');
// back compatiblity
foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
$latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
}
// default parameters
$template->control = $template->_control = $control;
$template->presenter = $template->_presenter = $presenter;
$template->user = $this->user;
$template->netteHttpResponse = $this->httpResponse;
$template->netteCacheStorage = $this->cacheStorage;
$template->baseUri = $template->baseUrl = rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/');
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
$template->flashes = array();
if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
$id = $control->getParameterId('flash');
$template->flashes = (array) $presenter->getFlashSession()->{$id};
}
return $template;
}
示例8: getPresenter
/** Nette\Application\UI\PresenterComponent */
public function getPresenter($need = TRUE)
{
return $this->control->getPresenter($need);
}
示例9: renderSnippets
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);
}
}
示例10:
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