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


PHP ViewModel::getTemplate方法代码示例

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


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

示例1: testPartialOption

 public function testPartialOption()
 {
     $options = ['partial' => 'my/custom/partial'];
     $this->view->expects($this->once())->method('partial')->with(dirname($this->viewModel->getTemplate()) . '/' . $options['partial']);
     $helper = $this->helper;
     $helper($this->validData(), $options);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:7,代码来源:ApplyButtonsTest.php

示例2: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var \Zend\Mvc\Application $app */
     $app = $serviceLocator->get('Application');
     /** @var \Zend\Mvc\Router\Http\RouteMatch $routeMatch */
     $routeMatch = $app->getMvcEvent()->getRouteMatch();
     if ($routeMatch->getParam('viewModel')) {
         $viewModel = $serviceLocator->get($routeMatch->getParam('viewModel'));
         if (!$viewModel instanceof ViewModel) {
             throw new \RuntimeException('ViewModel must be instance of ' . ViewModel::class);
         }
     } else {
         $viewModel = new ViewModel();
     }
     if (!$viewModel->getTemplate()) {
         $template = $routeMatch->getParam('template');
         if ($template) {
             if (!is_string($template)) {
                 throw new \RuntimeException('Parameter template must be string');
             }
             $viewModel->setTemplate($template);
         }
     }
     return $viewModel;
 }
开发者ID:sebaks,项目名称:zend-mvc-controller,代码行数:25,代码来源:ViewModelFactory.php

示例3: testSetLayoutTemplate

 public function testSetLayoutTemplate()
 {
     $listener = new LayoutTemplateListener($this->layoutUpdater);
     $layout = new ViewModel();
     $this->assertEmpty($layout->getTemplate());
     $event = new \Zend\Mvc\MvcEvent();
     $event->setViewModel($layout);
     $listener->setLayoutTemplate($event);
     $this->assertEquals('2cols-left', $layout->getTemplate());
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:10,代码来源:LayoutTemplateListenerTest.php

示例4: testLayoutCanBeInjectedWithSetter

 public function testLayoutCanBeInjectedWithSetter()
 {
     $layout = new ViewModel();
     $layout->setTemplate('layout.phtml');
     $viewModel = new ViewModel();
     $viewModel->setTemplate('index.phtml');
     $zendView = $this->prophesize(ZendView::class);
     $zendView->render(Argument::that(function ($viewModel) {
         $this->assertEquals('layout.phtml', $viewModel->getTemplate());
         return true;
     }))->willReturn('OUTPUT');
     $view = new View($zendView->reveal());
     $view->setLayout($layout);
     $output = $view->render($viewModel);
     $this->assertEquals('OUTPUT', $output);
 }
开发者ID:mtymek,项目名称:blast-view,代码行数:16,代码来源:ViewTest.php

示例5: dashboardAction

 public function dashboardAction()
 {
     $model = new ViewModel();
     $model->setTemplate('core/index/dashboard');
     $widgets = array();
     $modules = $this->getServiceLocator()->get('ModuleManager')->getLoadedModules();
     $widgets = array();
     foreach ($this->config('dashboard', array_keys($modules)) as $module => $cfg) {
         if (!isset($cfg['enabled']) || true !== $cfg['enabled']) {
             continue;
         }
         foreach ($cfg['widgets'] as $captureTo => $spec) {
             if (isset($spec['controller'])) {
                 $params = array('action' => 'dashboard');
                 if (isset($spec['params'])) {
                     $params = array_merge($params, $spec['params']);
                 }
                 $viewModel = $this->forward()->dispatch($spec['controller'], $params);
                 // we ignore all errors and simply continue with the error template as widget content
                 $response = $this->getResponse();
                 if (200 != $response->getStatusCode()) {
                     $response->setStatusCode(200);
                     $viewModel = array('content' => 'Error loading widget.');
                 }
                 if (!$viewModel instanceof ViewModel) {
                     $viewModel = new ViewModel($viewModel);
                 }
                 if ($template = $viewModel->getTemplate()) {
                     $viewModel->setVariable('script', $template);
                 }
             } else {
                 if (isset($spec['script'])) {
                     $viewModel = new ViewModel(array('script' => $spec['script']));
                 } else {
                     if (isset($spec['content'])) {
                         $viewModel = new ViewModel(array('content' => $spec['content']));
                     }
                 }
             }
             $viewModel->setTemplate('core/index/dashboard-widget.phtml');
             $model->addChild($viewModel, "dashboard_{$module}_{$captureTo}");
             //$widgets[] = $viewModel;
         }
     }
     //$model->setVariable('widgets', $widgets);
     return $model;
 }
开发者ID:bitrecruiter,项目名称:CrossApplicantManager,代码行数:47,代码来源:IndexController.php

示例6: testTemplateIsMutable

 public function testTemplateIsMutable()
 {
     $model = new ViewModel();
     $model->setTemplate('foo');
     $this->assertEquals('foo', $model->getTemplate());
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:6,代码来源:ViewModelTest.php

示例7: canonizeActionResult

 /**
  * Inspect the result, and cast it to a ViewModel
  *
  * @param  MvcEvent $e
  * @return void
  */
 public function canonizeActionResult(MvcEvent $e)
 {
     $result = $e->getResult();
     if ($result instanceof Response) {
         return;
     }
     // MVC controller
     $controller = $e->getTarget();
     // Controller view
     $controllerVew = $controller->plugin('view');
     // Collect captured contents
     if ($this->obStarted) {
         $content = ob_get_clean();
         if ($content) {
             if (null === $result && !$controllerVew->hasViewModel()) {
                 $result = $content;
             } elseif (Pi::service()->hasService('log')) {
                 Pi::service('log')->info('Captured content: ' . $content);
             }
         }
     }
     // Skip scalar result
     if (!$this->type && is_scalar($result) && !is_bool($result)) {
         if ($controllerVew->hasViewModel()) {
             $viewModel = $controllerVew->getViewModel();
         } else {
             $viewModel = new ViewModel();
         }
         $viewModel->setTemplate('__NULL__');
         $viewModel->setVariable($viewModel->captureTo(), $result);
         $e->setResult($viewModel);
         return;
     }
     // ViewModel generated by controller
     $viewModel = null;
     // Cast controller ViewModel
     if ($controllerVew->hasViewModel()) {
         $viewModel = $controllerVew->getViewModel();
         $template = $viewModel->getTemplate();
         // Controller ViewModel is as the main model if if if is specified
         // with template, MvcEvent result is converted to variables of
         // the ViewModel
         if ($viewModel instanceof ViewModel && !$viewModel instanceof JsonModel && !$viewModel instanceof FeedModel && $template && '__NULL__' != $template) {
             $variables = array();
             $options = array();
             if ($result instanceof ViewModel) {
                 $variables = $result->getVariables();
                 $options = $result->getOptions();
             } elseif ($result instanceof FeedDataModel) {
                 $variables = (array) $result;
                 $options = array('feed_type' => $result->getType());
             } elseif (ArrayUtils::hasStringKeys($result, true)) {
                 $variables = array_merge_recursive($variables, $result);
             }
             $viewModel->setVariables($variables);
             $viewModel->setOptions($options);
             $e->setResult($viewModel);
             return;
         }
     }
     // Set type to json if no template is specified
     if (!$this->type && null !== $result) {
         $skip = false;
         if ($result instanceof ViewModel && $result->getTemplate() && $result->getTemplate() != '__NULL__' || $result instanceof JsonModel || $result instanceof FeedModel) {
             $skip = true;
         }
         if (!$skip) {
             $this->type = 'json';
             Pi::service('log')->mute();
         }
     }
     // Cast controller view model to result ViewModel
     switch ($this->type) {
         // For Feed
         case 'feed':
             if ($result instanceof FeedModel) {
                 $model = $result;
             } else {
                 $variables = array();
                 //$options = array();
                 if ($result instanceof ViewModel) {
                     $variables = $result->getVariables();
                     $options = $result->getOptions();
                 } elseif ($result instanceof FeedDataModel) {
                     $variables = (array) $result;
                     $options = array('feed_type' => $result->getType());
                 } else {
                     if ($viewModel) {
                         $variables = $viewModel->getVariables();
                         //$options = $viewModel->getOptions();
                     }
                     if (ArrayUtils::hasStringKeys($result, true)) {
                         $variables = array_merge_recursive((array) $variables, (array) $result);
                     }
//.........这里部分代码省略.........
开发者ID:Andyyang1981,项目名称:pi,代码行数:101,代码来源:ViewStrategyListener.php

示例8: getEmailTemplate

 /**
  * Get email template
  *
  * @return string
  */
 public function getEmailTemplate()
 {
     return $this->viewModel->getTemplate();
 }
开发者ID:ralfeggert,项目名称:travello-lib,代码行数:9,代码来源:AbstractMailer.php


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