本文整理汇总了PHP中Zend\View\Model\ModelInterface::setCaptureTo方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelInterface::setCaptureTo方法的具体用法?PHP ModelInterface::setCaptureTo怎么用?PHP ModelInterface::setCaptureTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Model\ModelInterface
的用法示例。
在下文中一共展示了ModelInterface::setCaptureTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addChild
/**
* Add a child model
*
* @param ModelInterface $child
* @param null|string $captureTo Optional; if specified, the "capture to" value to set on the child
* @param null|bool $append Optional; if specified, append to child with the same capture
* @return ViewModel
*/
public function addChild(ModelInterface $child, $captureTo = null, $append = null)
{
$this->children[] = $child;
if (null !== $captureTo) {
$child->setCaptureTo($captureTo);
}
if (null !== $append) {
$child->setAppend($append);
}
return $this;
}
示例2: populateViewModel
/**
* Populate the view model returned by the AcceptableViewModelSelector from the result
*
* If the result is a ViewModel, we "re-cast" it by copying over all
* values/settings/etc from the original.
*
* If the result is an array, we pass those values as the view model variables.
*
* @param array|ViewModel $result
* @param ViewModelInterface $viewModel
* @param MvcEvent $e
*/
protected function populateViewModel($result, ViewModelInterface $viewModel, MvcEvent $e)
{
if ($result instanceof ViewModel) {
// "Re-cast" content-negotiation view models to the view model type
// selected by the AcceptableViewModelSelector
$viewModel->setVariables($result->getVariables());
$viewModel->setTemplate($result->getTemplate());
$viewModel->setOptions($result->getOptions());
$viewModel->setCaptureTo($result->captureTo());
$viewModel->setTerminal($result->terminate());
$viewModel->setAppend($result->isAppend());
if ($result->hasChildren()) {
foreach ($result->getChildren() as $child) {
$viewModel->addChild($child);
}
}
$e->setResult($viewModel);
return;
}
// At this point, the result is an array; use it to populate the view
// model variables
$viewModel->setVariables($result);
$e->setResult($viewModel);
}