當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ModelInterface::setOption方法代碼示例

本文整理匯總了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;
 }
開發者ID:hummer2k,項目名稱:conlayout,代碼行數:40,代碼來源:BlockFactory.php

示例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;
 }
開發者ID:hummer2k,項目名稱:conlayout,代碼行數:13,代碼來源:BlockPool.php

示例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);
 }
開發者ID:adamdyson,項目名稱:ConLayout,代碼行數:28,代碼來源:BlockFactory.php


注:本文中的Zend\View\Model\ModelInterface::setOption方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。