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


PHP ModelInterface::getVariable方法代码示例

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


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

示例1: render

 /**
  * Processes a view script and returns the output.
  *
  * @param  string|ModelInterface $nameOrModel The script/resource process, or a view model
  * @param  null|array|\ArrayAccess $values Values to use during rendering
  * @return string The script output.
  */
 public function render($nameOrModel, $values = null)
 {
     $string = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//hacksw/handcal//NONSGML v1.0//EN\n";
     foreach ($nameOrModel->getVariable('events') as $event) {
         $string .= "BEGIN:VEVENT\n";
         $string .= "UID:{$event->id}@stjornvisi.is\n";
         $string .= "DTSTART:{$event->event_time->format('Ymd\\THis')}\n";
         $string .= "DTEND:{$event->event_end->format('Ymd\\THis')}\n";
         if ($event->lat && $event->lng) {
             $string .= "GEO:{$event->lat};{$event->lng}\n";
         }
         $string .= "LOCATION:{$event->location}\n";
         $string .= "ORGANIZER;CN=\"" . ($event->groups ? implode(', ', array_map(function ($g) {
             return $g->name;
         }, $event->groups)) : 'Stjónvísisviðburður') . "\":no-reply@stjornvisi.is\n";
         $string .= "LOCATION:{$event->location}\n";
         $string .= "URL:http://{$_SERVER['SERVER_NAME']}/vidburdir/{$event->id}\n";
         $string .= "SUMMARY:{$event->subject}\n";
         $string .= "END:VEVENT\n";
     }
     $string .= "END:VCALENDAR";
     return $string;
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:30,代码来源:IcalRenderer.php

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

示例3: 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::getVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。