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


PHP ViewModel::getVariables方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     try {
         $object = $this->getUuidManager()->getUuid($this->params('uuid'), true);
     } catch (NotFoundException $e) {
         $this->getResponse()->setStatusCode(404);
         return false;
     }
     $normalized = $this->getNormalizer()->normalize($object);
     $routeName = $normalized->getRouteName();
     $routeParams = $normalized->getRouteParams();
     $type = $normalized->getType();
     $url = $this->url()->fromRoute($routeName, $routeParams, null, null, false);
     if (!$this->getRequest()->isXmlHttpRequest()) {
         $url = $this->url()->fromRoute($routeName, $routeParams);
         $response = $this->redirect()->toUrl($url);
         $this->getResponse()->setStatusCode(301);
         return $response;
     }
     $router = $this->getServiceLocator()->get('Router');
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     $request->setUri($url);
     $routeMatch = $router->match($request);
     if (!$routeMatch) {
         throw new RuntimeException(sprintf('Could not match a route for `%s`', $url));
     }
     $params = array_merge($routeMatch->getParams(), ['forwarded' => true, 'isXmlHttpRequest' => true]);
     $controller = $params['controller'];
     $response = $this->forward()->dispatch($controller, $params);
     // TODO: Do me a favor and remove this piece of cr*p with something that doesn't hack the whole thing
     if ($response instanceof JsonModel) {
         $response = new ViewModel(['data' => $response->getVariables()]);
         $response->setTemplate('normalizer/json');
     }
     $view = new ViewModel(['id' => $object->getId(), 'type' => $type, 'url' => $url, '__disableTemplateDebugger' => true]);
     $view->addChild($response, 'response');
     $view->setTemplate('normalizer/ref');
     $view->setTerminal(true);
     return $view;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:41,代码来源:SignpostController.php

示例2: testIfViewModelComposesVariablesInstanceThenRendererUsesIt

 /**
  * @group view-model
  */
 public function testIfViewModelComposesVariablesInstanceThenRendererUsesIt()
 {
     $model = new ViewModel();
     $model->setTemplate('template');
     $vars = $model->getVariables();
     $vars['foo'] = 'BAR-BAZ-BAT';
     $resolver = new TemplateMapResolver(array('template' => __DIR__ . '/_templates/view-model-variables.phtml'));
     $this->renderer->setResolver($resolver);
     $test = $this->renderer->render($model);
     $this->assertContains('BAR-BAZ-BAT', $test);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:14,代码来源:PhpRendererTest.php

示例3: testPropertyOverloadingAllowsWritingPropertiesAfterSetVariablesHasBeenCalled

 public function testPropertyOverloadingAllowsWritingPropertiesAfterSetVariablesHasBeenCalled()
 {
     $model = new ViewModel();
     $model->setVariables(array('foo' => 'bar'));
     $model->bar = 'baz';
     $this->assertTrue(isset($model->bar));
     $this->assertEquals('baz', $model->bar);
     $variables = $model->getVariables();
     $this->assertTrue(isset($variables['bar']));
     $this->assertEquals('baz', $variables['bar']);
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:11,代码来源:ViewModelTest.php

示例4: testPropertyOverloadingGivesAccessToProperties

 public function testPropertyOverloadingGivesAccessToProperties()
 {
     $model = new ViewModel();
     $variables = $model->getVariables();
     $model->foo = 'bar';
     $this->assertTrue(isset($model->foo));
     $this->assertEquals('bar', $variables['foo']);
     $this->assertEquals('bar', $model->foo);
     unset($model->foo);
     $this->assertFalse(isset($model->foo));
     $this->assertFalse(isset($variables['foo']));
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:12,代码来源:ViewModelTest.php

示例5: _setStrictVars

 /**
  * Set strict vars on a view model recursively
  *
  * @param \Zend\View\Model\ViewModel $model
  */
 protected function _setStrictVars(\Zend\View\Model\ViewModel $model)
 {
     $vars = $model->getVariables();
     if (!$vars instanceof \Zend\View\Variables) {
         $vars = new \Zend\View\Variables($vars);
     }
     $vars->setStrictVars(true);
     $model->setVariables($vars, true);
     foreach ($model->getChildren() as $child) {
         $this->_setStrictVars($child);
     }
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:17,代码来源:Module.php


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