當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。