本文整理匯總了PHP中Zend\View\Model\ModelInterface::setOption方法的典型用法代碼示例。如果您正苦於以下問題:PHP ModelInterface::setOption方法的具體用法?PHP ModelInterface::setOption怎麽用?PHP ModelInterface::setOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\View\Model\ModelInterface
的用法示例。
在下文中一共展示了ModelInterface::setOption方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: configure
/**
* @inheritDoc
*/
public function configure(ModelInterface $block, array $specs)
{
$specs = $this->prepareOptions($specs);
foreach ($this->getOption('options', $specs) as $name => $option) {
$block->setOption($name, $option);
}
foreach ($this->getOption('variables', $specs) as $name => $variable) {
$block->setVariable($name, $variable);
}
foreach ($this->getOption('actions', $specs) as $params) {
if (isset($params['method'])) {
$method = (string) $params['method'];
if (method_exists($block, $method)) {
$this->invokeArgs($block, $method, $params);
} else {
throw new BadMethodCallException(sprintf('Call to undefined block method %s::%s()', get_class($block), $method));
}
}
}
if (!$block->getTemplate() && ($template = $this->getOption('template', $specs))) {
$block->setTemplate($template);
}
$block->setCaptureTo($this->getOption('capture_to', $specs));
$block->setAppend($this->getOption('append', $specs));
$block->setVariable('block', $block);
if ($block instanceof BlockInterface) {
$block->setView($this->container->get('ViewRenderer'));
$block->setRequest($this->container->get('Request'));
}
$results = $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, ['block' => $block, 'specs' => $specs], function ($result) {
return $result instanceof ModelInterface;
});
if ($results->stopped()) {
$block = $results->last();
}
return $block;
}
示例2: determineAnonymousBlockId
/**
* @param ModelInterface $block
* @return mixed|string
*/
private function determineAnonymousBlockId(ModelInterface $block)
{
$blockId = $block->getOption('block_id');
if (!$blockId) {
$blockId = sprintf(self::ANONYMOUS_ID_PATTERN, $block->captureTo(), self::$anonymousSuffix++);
$block->setOption('block_id', $blockId);
}
return $blockId;
}
示例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);
}