当前位置: 首页>>代码示例>>PHP>>正文


PHP ModelInterface::setVariable方法代码示例

本文整理汇总了PHP中Zend\View\Model\ModelInterface::setVariable方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelInterface::setVariable方法的具体用法?PHP ModelInterface::setVariable怎么用?PHP ModelInterface::setVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\View\Model\ModelInterface的用法示例。


在下文中一共展示了ModelInterface::setVariable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: notFoundByRequestedCriteria

 /**
  * @return mixed
  */
 public function notFoundByRequestedCriteria($criteriaErrors)
 {
     $zendResponse = $this->mvcEvent->getResponse();
     $zendResponse->setStatusCode(404);
     $this->viewModel->setVariable('message', 'The requested resource was not found by requested criteria');
     $this->viewModel->setTemplate('error/404');
     $this->mvcEvent->setResult($this->viewModel);
     return $this->viewModel;
 }
开发者ID:sebaks,项目名称:zend-mvc-controller,代码行数:12,代码来源:HtmlError.php

示例2: renderChildren

 /**
  *
  * @param ModelInterface $model
  */
 protected function renderChildren(ModelInterface $model)
 {
     foreach ($model->getChildren() as $child) {
         $result = $this->render($child);
         $capture = $child->captureTo();
         if (!empty($capture)) {
             if ($child->isAppend()) {
                 $oldResult = $model->{$capture};
                 $model->setVariable($capture, $oldResult . $result);
             } else {
                 $model->setVariable($capture, $result);
             }
         }
     }
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:19,代码来源:BlockRenderer.php

示例3: renderChildren

 /**
  * @param \Zend\View\Model\ModelInterface $oViewModel
  * @throws \DomainException
  * @return \BoilerAppMessenger\Media\Mail\MailMessageRenderer
  */
 protected function renderChildren(\Zend\View\Model\ModelInterface $oViewModel)
 {
     foreach ($oViewModel as $oChild) {
         if ($oChild->terminate()) {
             throw new \DomainException('Inconsistent state; child view model is marked as terminal');
         }
         $oChild->setOption('has_parent', true);
         $sResult = $this->renderChildren($oChild)->render($oChild);
         $oChild->setOption('has_parent', null);
         $sCapture = $oChild->captureTo();
         if (!empty($sCapture)) {
             $oViewModel->setVariable($sCapture, $oChild->isAppend() ? $oViewModel->{$sCapture} . $sResult : $sResult);
         }
     }
     return $this;
 }
开发者ID:zf2-boiler-app,项目名称:app-messenger,代码行数:21,代码来源:MailMessageRenderer.php

示例4: renderChildren

 /**
  * Loop through children, rendering each
  *
  * @param  Model $model
  * @throws Exception\DomainException
  * @return void
  */
 protected function renderChildren(Model $model)
 {
     foreach ($model as $child) {
         if ($child->terminate()) {
             throw new Exception\DomainException('Inconsistent state; child view model is marked as terminal');
         }
         $child->setOption('has_parent', true);
         $result = $this->render($child);
         $child->setOption('has_parent', null);
         $capture = $child->captureTo();
         if (!empty($capture)) {
             if ($child->isAppend()) {
                 $oldResult = $model->{$capture};
                 $model->setVariable($capture, $oldResult . $result);
             } else {
                 $model->setVariable($capture, $result);
             }
         }
     }
 }
开发者ID:jbmchd,项目名称:semente.lanches,代码行数:27,代码来源:View.php

示例5: injectChildren

 /**
  * Inject discovered child model values into parent model
  *
  * @todo   detect collisions and decide whether to append and/or aggregate?
  * @param  Model $model
  * @param  array $children
  */
 protected function injectChildren(Model $model, array $children)
 {
     foreach ($children as $child => $value) {
         // TODO detect collisions and decide whether to append and/or aggregate?
         $model->setVariable($child, $value);
     }
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:14,代码来源:JsonRenderer.php

示例6: renderModel

 /**
  * Do a recursive, depth-first rendering of a view model.
  *
  * @param ModelInterface $model
  * @param RendererInterface $renderer
  * @return string
  * @throws Exception\RenderingException if it encounters a terminal child.
  */
 private function renderModel(ModelInterface $model, RendererInterface $renderer)
 {
     foreach ($model as $child) {
         if ($child->terminate()) {
             throw new Exception\RenderingException('Cannot render; encountered a child marked terminal');
         }
         $capture = $child->captureTo();
         if (empty($capture)) {
             continue;
         }
         $result = $this->renderModel($child, $renderer);
         if ($child->isAppend()) {
             $oldResult = $model->{$capture};
             $model->setVariable($capture, $oldResult . $result);
             continue;
         }
         $model->setVariable($capture, $result);
     }
     return $renderer->render($model);
 }
开发者ID:samsonasik,项目名称:zend-expressive-zendviewrenderer,代码行数:28,代码来源:ZendViewRenderer.php

示例7: 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

示例8: determineAnonymousBlockId

 /**
  *
  * @param ViewModel $block
  * @return string
  */
 protected function determineAnonymousBlockId(ModelInterface $block)
 {
     $blockId = $block->getVariable(self::BLOCK_ID_VAR);
     if (!$blockId) {
         $blockId = sprintf(self::ANONYMOUS_ID_PATTERN, $block->captureTo(), self::$anonymousSuffix++);
         $block->setVariable(self::BLOCK_ID_VAR, $blockId);
     }
     return $blockId;
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:14,代码来源:Layout.php

示例9: 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

示例10: addVariable

 /**
  * Add a variable to the View Model
  * 
  * @param string $name
  * @param mixed $value
  */
 protected function addVariable($name, $value)
 {
     $this->model->setVariable($name, $value);
 }
开发者ID:sporkcode,项目名称:spork,代码行数:10,代码来源:TestCaseView.php

示例11: attachToView

 /**
  * Add acl to the view model
  *
  * @param ModelInterface $viewModel
  *
  * @return mixed
  */
 public function attachToView(ModelInterface $viewModel)
 {
     $viewModel->setVariable('acl', $this->getAcl());
     return $this;
 }
开发者ID:fousheezy,项目名称:auth,代码行数:12,代码来源:Base.php

示例12: prepareLayout

 /**
  * Prepare the layout, if any.
  *
  * Injects the view model in the layout view model, if present.
  *
  * If the view model contains a non-empty 'layout' variable, that value
  * will be used to seed a layout view model, if:
  *
  * - it is a string layout template name
  * - it is a ModelInterface instance
  *
  * If a layout is discovered in this way, it will override the one set in
  * the constructor, if any.
  *
  * Returns the provided $viewModel unchanged if no layout is discovered;
  * otherwise, a view model representing the layout, with the provided
  * view model as a child, is returned.
  *
  * @param ModelInterface $viewModel
  * @return ModelInterface
  */
 private function prepareLayout(ModelInterface $viewModel)
 {
     $layout = $this->layout ? clone $this->layout : null;
     $providedLayout = $viewModel->getVariable('layout', false);
     if (is_string($providedLayout) && !empty($providedLayout)) {
         $layout = new ViewModel();
         $layout->setTemplate($providedLayout);
         $viewModel->setVariable('layout', null);
     } elseif ($providedLayout instanceof ModelInterface) {
         $layout = $providedLayout;
         $viewModel->setVariable('layout', null);
     }
     if ($layout) {
         $layout->addChild($viewModel);
         $viewModel = $layout;
     }
     return $viewModel;
 }
开发者ID:fabiocarneiro,项目名称:zend-expressive-zendviewrenderer,代码行数:39,代码来源:ZendViewRenderer.php


注:本文中的Zend\View\Model\ModelInterface::setVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。