本文整理汇总了PHP中Zend\View\Model\ModelInterface::getTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelInterface::getTemplate方法的具体用法?PHP ModelInterface::getTemplate怎么用?PHP ModelInterface::getTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Model\ModelInterface
的用法示例。
在下文中一共展示了ModelInterface::getTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Processes a view script and returns the output.
*
* @param string|ModelInterface $nameOrModel The script/resource process, or a view model
* @param null|array|\ArrayAccess $values Values to use during rendering
* @return string The script output.
* @throws \LogicException
*/
public function render($nameOrModel, $values = null)
{
$name = $nameOrModel;
if ($nameOrModel instanceof ModelInterface) {
$name = $this->resolver->resolve($nameOrModel->getTemplate(), $this);
$values = (array) $nameOrModel->getVariables();
}
if (array_key_exists('helper', $values)) {
throw new \LogicException('Variable $helper is reserved for Zend helpers and can\'t be passed to view.');
}
$values['helper'] = $this->helpers;
return $this->engine->renderToString($name, $values);
}
示例2: searchTemplates
/**
* Recursively search a view model and it's children for the given templateName
*
* @param \Zend\View\Model\ModelInterface $viewModel
* @param string $templateName
* @return boolean
*/
protected function searchTemplates($viewModel, $templateName)
{
if ($viewModel->getTemplate($templateName) == $templateName) {
return true;
}
foreach ($viewModel->getChildren() as $child) {
return $this->searchTemplates($child, $templateName);
}
return false;
}
示例3: wrapBlock
/**
* assign wrapper template to block
*
* @param ModelInterface $block
* @param array|string $options
*/
protected function wrapBlock(ModelInterface $block, $options)
{
$attributes = $options;
if (is_string($options)) {
$wrapperTemplate = $options;
$attributes = [];
} elseif (is_array($options) && !isset($options['template'])) {
$wrapperTemplate = self::WRAPPER_DEFAULT;
} else {
$wrapperTemplate = $options['template'];
unset($attributes['template']);
}
if (isset($options['tag'])) {
$block->setVariable('wrapperTag', $options['tag']);
unset($attributes['tag']);
}
$originalTemplate = $block->getTemplate();
$block->setOption('is_wrapped', true);
$block->setTemplate($wrapperTemplate);
$block->setVariable('wrapperAttributes', $attributes);
$block->setVariable('originalTemplate', $originalTemplate);
}