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


PHP ModelInterface::setVariables方法代码示例

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


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

示例1: onDispatch

 /**
  * @param MvcEvent $e
  * @return mixed|\Zend\Http\Response|ViewModelInterface
  */
 public function onDispatch(MvcEvent $e)
 {
     if (!empty($this->options['allowedMethods']) && !in_array($this->sebaksRequest->getMethod(), $this->options['allowedMethods'])) {
         return $this->error->methodNotAllowed();
     }
     $e->setParam('sebaksRequest', $this->sebaksRequest);
     $e->setParam('sebaksResponse', $this->sebaksResponse);
     $routeName = $e->getRouteMatch()->getMatchedRouteName();
     $this->getEventManager()->trigger("dispatch.{$routeName}.pre", $e);
     $this->controller->dispatch($this->sebaksRequest, $this->sebaksResponse);
     $this->getEventManager()->trigger("dispatch.{$routeName}.post", $e);
     $criteriaErrors = $this->sebaksResponse->getCriteriaErrors();
     if (!empty($criteriaErrors)) {
         return $this->error->notFoundByRequestedCriteria($criteriaErrors);
     }
     $changesErrors = $this->sebaksResponse->getChangesErrors();
     $redirectTo = $this->sebaksResponse->getRedirectTo();
     if (empty($changesErrors) && !empty($redirectTo)) {
         if (is_array($redirectTo)) {
             if (!isset($redirectTo['route'])) {
                 throw new \RuntimeException('Missing required parameter route');
             }
             $routeParams = isset($redirectTo['params']) ? $redirectTo['params'] : [];
             $routeOptions = isset($redirectTo['options']) ? $redirectTo['options'] : [];
             return $this->redirect()->toRoute($redirectTo['route'], $routeParams, $routeOptions);
         } else {
             return $this->redirect()->toRoute($redirectTo);
         }
     }
     if (!empty($changesErrors)) {
         $result = $this->error->changesErrors($changesErrors);
         if ($result instanceof Response) {
             return $result;
         }
     }
     $this->viewModel->setVariables($this->sebaksResponse->toArray());
     $e->setResult($this->viewModel);
     return $this->viewModel;
 }
开发者ID:sebaks,项目名称:zend-mvc-controller,代码行数:43,代码来源:Controller.php

示例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);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:36,代码来源:AcceptListener.php

示例3: setVariables

 /**
  * Set a list of variables in the View Model
  * @param array $variables
  */
 protected function setVariables(array $variables)
 {
     $this->model->setVariables($variables);
 }
开发者ID:sporkcode,项目名称:spork,代码行数:8,代码来源:TestCaseView.php

示例4: mergeViewModel

 /**
  * Merge global/template parameters with provided view model.
  *
  * @param string $name Template name.
  * @param ModelInterface $model
  * @return ModelInterface
  */
 private function mergeViewModel($name, ModelInterface $model)
 {
     $params = $this->mergeParams($name, $model->getVariables());
     $model->setVariables($params);
     $model->setTemplate($name);
     return $model;
 }
开发者ID:fabiocarneiro,项目名称:zend-expressive-zendviewrenderer,代码行数:14,代码来源:ZendViewRenderer.php


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