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


PHP Model\ModelInterface类代码示例

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


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

示例1: render

 /**
  * Render values as XML
  *
  * @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)
 {
     if ($nameOrModel instanceof XmlModel) {
         return $nameOrModel->serialize();
     }
     // use case 3: Both $nameOrModel and $values are populated
     throw new Exception\DomainException(sprintf('%s: Do not know how to handle operation when both $nameOrModel and $values are populated', __METHOD__));
 }
开发者ID:zpetr,项目名称:ApigilityXml,代码行数:15,代码来源:XmlRenderer.php

示例2: render

 /**
  * Renders values as Icalendar
  *
  * @param string|\Zend\View\Model\ModelInterface $oNameOrModel : the script/resource process, or a view model
  * @param null|array|\ArrayAccess $aValues : values to use during rendering
  *
  * @throws \DomainException
  * @return string The script output.
  */
 public function render($oNameOrModel, $aValues = null)
 {
     // Use case 1: View Models
     // Serialize variables in view model
     if (!$oNameOrModel instanceof IcalendarModel) {
         throw new \DomainException(__METHOD__ . ': Do not know how to handle operation when both $oNameOrModel and $aValues are populated');
     }
     return $oNameOrModel->serialize();
 }
开发者ID:krsreenatha,项目名称:php.ug,代码行数:18,代码来源:IcalendarRenderer.php

示例3: addChildrenToView

 /**
  * @param ModelInterface $viewModel
  * @param callable $addToViewFromModel
  */
 protected function addChildrenToView(ModelInterface $viewModel, $addToViewFromModel)
 {
     if ($viewModel->hasChildren()) {
         foreach ($viewModel->getChildren() as $child) {
             $addToViewFromModel($child);
             $this->addChildrenToView($child, $addToViewFromModel);
         }
     }
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:13,代码来源:RequestCollector.php

示例4: render

 /**
  * @param  string|\Zend\View\Model\ModelInterface $nameOrModel
  * @param  array|null $values
  * @return string
  */
 public function render($nameOrModel, $values = null)
 {
     if (!$nameOrModel instanceof ApiProblemModel) {
         return '';
     }
     $apiProblem = $nameOrModel->getApiProblem();
     if ($this->displayExceptions) {
         $apiProblem->setDetailIncludesStackTrace(true);
     }
     return parent::render($apiProblem->toArray());
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:16,代码来源:ApiProblemRenderer.php

示例5: render

 /**
  * Render the provided model.
  *
  * @param ModelInterface $model
  * @return string
  */
 public function render(ModelInterface $model)
 {
     if ($this->layout && !$model->terminate()) {
         $this->layout->addChild($model);
         $model = $this->layout;
     }
     // hack, force ZendView to return its output instead of triggering an event
     // see: http://mateusztymek.pl/blog/using-standalone-zend-view
     $model->setOption('has_parent', true);
     return $this->zendView->render($model);
 }
开发者ID:mtymek,项目名称:blast-view,代码行数:17,代码来源:View.php

示例6: 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.
  * @throws \LogicException
  */
 public function render($nameOrModel, $values = null)
 {
     $name = $nameOrModel;
     if ($nameOrModel instanceof ModelInterface) {
         $name = $this->resolver->resolve($nameOrModel->getTemplate(), $this);
         $values = (array) $nameOrModel->getVariables();
     }
     if (array_key_exists('helper', $values)) {
         throw new \LogicException('Variable $helper is reserved for Zend helpers and can\'t be passed to view.');
     }
     $values['helper'] = $this->helpers;
     return $this->engine->renderToString($name, $values);
 }
开发者ID:halaxa,项目名称:zf2-latte,代码行数:21,代码来源:LatteRenderer.php

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

示例8: render

 /**
  * @param string|ModelInterface $nameOrModel
  * @param null                  $values
  * @return string|void
  */
 public function render($nameOrModel, $values = null)
 {
     if ($nameOrModel instanceof CacheModel) {
         $key = $nameOrModel->getCacheKey();
         if (false === $nameOrModel->getIsFetchable()) {
             $cacheService = $this->getCacheService($key);
             $result = $this->getDefaultPhpRenderer()->render($nameOrModel, $values = null);
             $cacheService->setItem($key, $result);
             return $result;
         } else {
             return $nameOrModel->getContent();
         }
     }
     return $this->getDefaultPhpRenderer()->render($nameOrModel, $values = null);
 }
开发者ID:nbochenko,项目名称:cache,代码行数:20,代码来源:CacheStrategy.php

示例9: 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)
 {
     /** @var  $nameOrModel \Stjornvisi\View\Model\CsvModel */
     $csv = $nameOrModel->getData();
     /** @var $csv \Stjornvisi\Lib\Csv */
     $string = implode(",", array_map(function ($data) {
         return "\"" . addslashes($data) . "\"";
     }, $csv->getHeader())) . PHP_EOL;
     foreach ($csv as $item) {
         $string .= implode(",", array_map(function ($data) {
             return "\"" . addslashes($data) . "\"";
         }, $item));
         $string .= PHP_EOL;
     }
     return $string;
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:23,代码来源:CsvRenderer.php

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

示例11: render

 /**
  * Recursively processes all ViewModels and returns output.
  *
  * @param string|ModelInterface $model A ViewModel instance.
  * @param null|array|\Traversable $values Values to use when rendering. If
  *     none provided, uses those in the composed variables container.
  * @return string Console output.
  */
 public function render($model, $values = null)
 {
     $result = '';
     if (!$model instanceof ModelInterface) {
         // View model is required by this renderer
         return $result;
     }
     // If option keys match setters, pass values to those methods.
     foreach ($model->getOptions() as $setting => $value) {
         $method = 'set' . $setting;
         if (method_exists($this, $method)) {
             $this->{$method}($value);
         }
     }
     // Render children first
     if ($model->hasChildren()) {
         // recursively render all children
         foreach ($model->getChildren() as $child) {
             $result .= $this->render($child, $values);
         }
     }
     // Render the result, if present.
     $values = $model->getVariables();
     if (isset($values['result']) && !isset($this->filterChain)) {
         // append the result verbatim
         $result .= $values['result'];
     }
     if (isset($values['result']) && isset($this->filterChain)) {
         // filter and append the result
         $result .= $this->getFilterChain()->filter($values['result']);
     }
     return $result;
 }
开发者ID:zendframework,项目名称:zend-mvc-console,代码行数:41,代码来源:Renderer.php

示例12: render

 /**
  * Renders values as a PDF
  *
  * @param string|ModelInterface|PdfModel $nameOrModel
  * @param  null|array|\ArrayAccess Values to use during rendering
  * @return string The script output.
  */
 public function render($nameOrModel, $values = null)
 {
     $pdfOptions = $nameOrModel->getPdfOptions();
     $paperSize = explode(',', $pdfOptions->getPaperSize());
     $paperOrientation = $pdfOptions->getPaperOrientation();
     $basePath = $pdfOptions->getBasePath();
     $paperSize = count($paperSize) === 1 ? $paperSize[0] : $paperSize;
     $pdf = $this->getEngine();
     $pdf->setPaper($paperSize, $paperOrientation);
     $pdf->setBasePath($basePath);
     $html = $this->getHtmlRenderer()->render($nameOrModel, $values);
     $pdf->loadHtml($html);
     $pdf->render();
     $pdf = $this->processHeader($pdf, $pdfOptions);
     $pdf = $this->processFooter($pdf, $pdfOptions);
     return $pdf->output();
 }
开发者ID:uthando-cms,项目名称:uthando-dompdf,代码行数:24,代码来源:PdfRenderer.php

示例13: getContentTypeFromModel

 /**
  * Determine the response content-type to return based on the view model.
  *
  * @param ApiProblemModel|HalJsonModel|\Zend\View\Model\ModelInterface $model
  * @return string The content-type to use.
  */
 private function getContentTypeFromModel($model)
 {
     if ($model instanceof ApiProblemModel) {
         return 'application/problem+json';
     }
     if ($model instanceof HalJsonModel && ($model->isCollection() || $model->isEntity())) {
         return 'application/hal+json';
     }
     return $this->contentType;
 }
开发者ID:zfcampus,项目名称:zf-hal,代码行数:16,代码来源:HalJsonStrategy.php

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

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


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