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


PHP ViewEvent::getRenderer方法代码示例

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


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

示例1: injectResponse

 /**
  * Inject the response
  *
  * Injects the response with the rendered content, and sets the content
  * type based on the detection that occurred during renderer selection.
  *
  * @param  ViewEvent $e
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result)) {
         // We don't have a string, and thus, no JSON
         return;
     }
     $model = $e->getModel();
     $contentType = $this->contentType;
     $response = $e->getResponse();
     if ($model instanceof ApiProblemModel) {
         $contentType = 'application/problem+json';
     } elseif ($model instanceof HalJsonModel && ($model->isCollection() || $model->isEntity())) {
         $contentType = 'application/hal+json';
     }
     /** @var Response $response */
     $response->setContent($result);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('content-type', $contentType);
 }
开发者ID:antarus,项目名称:mystra-pve,代码行数:33,代码来源:HalJsonStrategy.php

示例2: injectResponse

 /**
  * Inject the response with the PDF payload and appropriate Content-Type header
  *
  * @param  ViewEvent $e
  * @return void
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result)) {
         // @todo Potentially throw an exception here since we should *always* get back a result.
         return;
     }
     $response = $e->getResponse();
     $response->setContent($result);
     $response->getHeaders()->addHeaderLine('content-type', 'application/pdf');
     /* @var PdfOptions $pdfOptions */
     $pdfOptions = $e->getModel()->getPdfOptions();
     $fileName = $pdfOptions->getFileName();
     if (isset($fileName)) {
         if (substr($fileName, -4) != '.pdf') {
             $fileName .= '.pdf';
         }
         $response->getHeaders()->addHeaderLine('Content-Disposition', 'attachment; filename=' . $fileName);
     }
 }
开发者ID:uthando-cms,项目名称:uthando-dompdf,代码行数:31,代码来源:PdfStrategy.php

示例3: injectResponse

 /**
  * Inject the response with the feed payload and appropriate Content-Type header
  *
  * @param  ViewEvent $e
  * @return void
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result) && !$result instanceof Feed) {
         // We don't have a string, and thus, no feed
         return;
     }
     // If the result is a feed, export it
     if ($result instanceof Feed) {
         $result = $result->export($renderer->getFeedType());
     }
     // Get the content-type header based on feed type
     $feedType = $renderer->getFeedType();
     $feedType = 'rss' == $feedType ? 'application/rss+xml' : 'application/atom+xml';
     $model = $e->getModel();
     $charset = '';
     if ($model instanceof Model\FeedModel) {
         $feed = $model->getFeed();
         $charset = '; charset=' . $feed->getEncoding() . ';';
     }
     // Populate response
     $response = $e->getResponse();
     $response->setContent($result);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('content-type', $feedType . $charset);
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:37,代码来源:FeedStrategy.php

示例4: injectResponse

 /**
  * Inject the response
  *
  * Injects the response with the rendered content, and sets the content
  * type based on the detection that occurred during renderer selection.
  *
  * @param  ViewEvent $e
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result)) {
         // We don't have a string, and thus, no JSON
         return;
     }
     $model = $e->getModel();
     $contentType = $this->contentType;
     $response = $e->getResponse();
     if ($this->renderer->isApiProblem()) {
         $contentType = 'application/api-problem+json';
         $statusCode = $this->getStatusCodeFromApiProblem($this->renderer->getApiProblem());
         $response->setStatusCode($statusCode);
     } elseif ($model instanceof RestfulJsonModel && $model->isApiProblem()) {
         $contentType = 'application/api-problem+json';
         $statusCode = $this->getStatusCodeFromApiProblem($model->getPayload());
         $response->setStatusCode($statusCode);
     } elseif ($model instanceof RestfulJsonModel && ($model->isHalCollection() || $model->isHalResource())) {
         $contentType = 'application/hal+json';
     }
     // Populate response
     $response->setContent($result);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('content-type', $contentType);
 }
开发者ID:davidbrabrand,项目名称:PhlyRestfully,代码行数:39,代码来源:RestfulJsonStrategy.php

示例5: injectResponse

 /**
  * Populate the response object from the View
  *
  * Populates the content of the response object from the view rendering
  * results.
  *
  * @param  ViewEvent $e
  * @return void
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         return;
     }
 }
开发者ID:wizzvet,项目名称:ZffHtml2pdf,代码行数:16,代码来源:Html2PdfStrategy.php

示例6: injectResponse

 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result)) {
         // We don't have a string, and thus, no yaml
         return;
     }
     // Populate response
     /** @var Http\Response $response */
     $response = $e->getResponse();
     $response->setContent($result);
     /** @var Headers $headers */
     $headers = $response->getHeaders();
     $contentType = sprintf('application/x-yaml; charset=%s', $this->charset);
     $headers->addHeaderLine('content-type', $contentType);
     // Add content-transfer-encoding header in charset is multibyte
     if (in_array(strtoupper($this->charset), $this->multibyteCharsets)) {
         $headers->addHeaderLine('content-transfer-encoding', 'BINARY');
     }
 }
开发者ID:acelaya,项目名称:zf2-acyaml,代码行数:25,代码来源:YamlStrategy.php

示例7: injectResponse

 /**
  * @param ViewEvent $ev
  * @return void
  */
 public function injectResponse(ViewEvent $ev)
 {
     if ($ev->getRenderer() === $this->renderer) {
         $result = $ev->getResult();
         $response = $ev->getResponse();
         $response->setContent($result);
     }
 }
开发者ID:ngyuki,项目名称:zf2-smarty,代码行数:12,代码来源:SmartyStrategy.php

示例8: response

 public function response(ViewEvent $event)
 {
     $renderer = $event->getRenderer();
     if ($renderer instanceof IcalendarRenderer) {
         $response = $event->getResponse();
         $response->getHeaders()->addHeaderLine('Content-type', 'text/calendar; charset=utf-8');
         $response->setContent($event->getResult());
     }
 }
开发者ID:sporkcode,项目名称:spork,代码行数:9,代码来源:Icalendar.php

示例9: injectResponse

 /**
  * Populate the response object from the view
  *
  * Populates the content of the response object from the view rendering
  * results.
  *
  * @param ViewEvent $event
  * @return void
  */
 public function injectResponse(ViewEvent $event)
 {
     if ($event->getRenderer() !== $this->renderer) {
         return;
     }
     $result = $event->getResult();
     $response = $event->getResponse();
     $response->setContent($result);
 }
开发者ID:alancrisp,项目名称:zf2twig,代码行数:18,代码来源:TwigStrategy.php

示例10: injectResponse

 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         return false;
     }
     $result = $e->getResult();
     $response = $e->getResponse();
     $response->setContent($result);
 }
开发者ID:skillfish,项目名称:zf3-smarty-module,代码行数:10,代码来源:Strategy.php

示例11: injectResponse

 /**
  * {@inheritDoc}
  */
 public function injectResponse(ViewEvent $e)
 {
     // Test this again here to avoid running our extra code for non-API
     // requests.
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     parent::injectResponse($e);
     $model = $e->getModel();
     $e->getResponse()->setStatusCode($this->getResponseStatusCode($model));
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:16,代码来源:ApiJsonStrategy.php

示例12: injectResponse

 /**
  * Inject the response with the feed payload and appropriate Content-Type header
  *
  * @param  ViewEvent $e
  * @return void
  * @throws \Zend\Http\Exception\InvalidArgumentException
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         return;
     }
     $result = $e->getResult();
     /** @var HttpResponse $response */
     $response = $e->getResponse();
     $response->setContent($result);
     $headers = $response->getHeaders();
     //$headers->addHeaderLine('Content-length', strlen($result));
     $headers->addHeaderLine('content-type', 'text/xml');
 }
开发者ID:old-town,项目名称:workflow-designer-server,代码行数:21,代码来源:WorkflowDescriptorApiStrategy.php

示例13: injectResponse

 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result)) {
         // We don't have a string, and thus, no YAML
         return;
     }
     // Populate response
     $response = $e->getResponse();
     $response->setContent($result);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('content-type', 'text/yaml');
 }
开发者ID:kidaa,项目名称:evedata,代码行数:18,代码来源:YamlStrategy.php

示例14: injectResponse

 /**
  * Inject the response
  *
  * Injects the response with the rendered content, and sets the content
  * type based on the detection that occurred during renderer selection.
  *
  * @param  ViewEvent $e
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!is_string($result)) {
         // We don't have a string, and thus, no JSON
         return;
     }
     $model = $e->getModel();
     $response = $e->getResponse();
     $response->setContent($result);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('content-type', $this->getContentTypeFromModel($model));
 }
开发者ID:zfcampus,项目名称:zf-hal,代码行数:26,代码来源:HalJsonStrategy.php

示例15: injectResponse

 /**
  * Inject the response with the JSON payload and appropriate Content-Type header
  *
  * @param  \Zend\View\ViewEvent $e
  * @return void
  */
 public function injectResponse(ViewEvent $e)
 {
     $renderer = $e->getRenderer();
     if ($renderer !== $this->renderer) {
         // Discovered renderer is not ours; do nothing
         return;
     }
     $result = $e->getResult();
     if (!$result instanceof NegotiatedResult) {
         // not a NegotiatedResult, we can't go on here
         return;
     }
     // Populate response
     $response = $e->getResponse();
     $response->setContent($result->content);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('content-type', $result->contentType);
 }
开发者ID:bedrest,项目名称:framework-zendframework2,代码行数:24,代码来源:ContentNegotiationStrategy.php


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