當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View\ViewEvent類代碼示例

本文整理匯總了PHP中Zend\View\ViewEvent的典型用法代碼示例。如果您正苦於以下問題:PHP ViewEvent類的具體用法?PHP ViewEvent怎麽用?PHP ViewEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ViewEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: testSelectRendererReturnsNullWhenApiBlueprintViewModelIsNotPresentInEvent

 public function testSelectRendererReturnsNullWhenApiBlueprintViewModelIsNotPresentInEvent()
 {
     $event = new ViewEvent();
     $event->setName(ViewEvent::EVENT_RENDERER);
     $this->assertNull($this->strategy->selectRenderer($event));
     return $event;
 }
開發者ID:BreiteSeite,項目名稱:zf-apigility-documentation-apiblueprint,代碼行數:7,代碼來源:ApiBlueprintViewStrategyTest.php

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

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

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

示例6: injectResponse

 /**
  * @param ViewEvent $e
  *
  * @return null
  *
  * @throws \Zend\Config\Exception\RuntimeException
  * @throws \Zend\Http\Exception\InvalidArgumentException
  */
 public function injectResponse(ViewEvent $e)
 {
     $model = $e->getModel();
     if (!$model instanceof ApiProblemModel) {
         // Model is not an ApiProblemModel; we cannot handle it here
         return null;
     }
     /** @var Request $request */
     $request = $e->getRequest();
     /** @var Accept $accept */
     $accept = $request->getHeader('Accept');
     if (!($accept instanceof Accept && $accept->hasMediaType('text/xml'))) {
         return null;
     }
     $problem = $model->getApiProblem();
     $statusCode = $this->getStatusCodeFromApiProblem($problem);
     $contentType = 'text/xml';
     /** @var Response $response */
     $response = $e->getResponse();
     $problemData = $problem->toArray();
     $xmlWriter = new XmlWriter();
     $output = $xmlWriter->processConfig($problemData);
     $response->setStatusCode($statusCode);
     $response->setContent($output);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('Content-Type', $contentType);
 }
開發者ID:old-town,項目名稱:workflow-designer-server,代碼行數:35,代碼來源:ApiProblemInjectResponse.php

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

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

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

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

示例11: testSelectRendererWithExtension

 public function testSelectRendererWithExtension()
 {
     $model = $this->getMock('Zend\\View\\Model\\ModelInterface');
     $model->expects($this->at(0))->method('getTemplate')->will($this->returnValue('test.md'));
     $event = new ViewEvent();
     $event->setModel($model);
     $result = $this->strategy->selectRenderer($event);
     $this->assertInstanceOf('Netorare\\View\\Renderer\\MarkdownRenderer', $result);
 }
開發者ID:sasezaki,項目名稱:netorare,代碼行數:9,代碼來源:PathinfoExtensionStrategyTest.php

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

示例13: testSelectRendererWhenTemplateFound

 public function testSelectRendererWhenTemplateFound()
 {
     $model = $this->getMock('Zend\\View\\Model\\ModelInterface');
     $model->expects($this->at(0))->method('getTemplate')->will($this->returnValue('key1'));
     $event = new ViewEvent();
     $event->setModel($model);
     $result = $this->strategy->selectRenderer($event);
     $this->assertSame($this->renderer, $result);
 }
開發者ID:shitikovkirill,項目名稱:zend-shop.com,代碼行數:9,代碼來源:TwigStrategyTest.php

示例14: processRcmResponses

 /**
  * Check for not authorized and redirect to the login page on 401.
  *
  * @param ViewEvent $event Zend MVC Event object
  *
  * @return null
  */
 public function processRcmResponses(ViewEvent $event)
 {
     $response = $event->getResponse();
     if (!$response instanceof RcmResponse) {
         return null;
     }
     $this->responseHandler->processResponse($response);
     return null;
 }
開發者ID:reliv,項目名稱:Rcm,代碼行數:16,代碼來源:ViewEventListener.php

示例15: selectRenderer

 /**
  * Detect if we should use the ResourceJsonRenderer based on model type
  *
  * @param ViewEvent $e
  * @return null|ResourceJsonRenderer|\Zend\View\Renderer\JsonRenderer
  */
 public function selectRenderer(ViewEvent $e)
 {
     $model = $e->getModel();
     if (!$model instanceof ResourceJsonModel) {
         // Not a Resource Json Model
         return;
     }
     return $this->renderer;
 }
開發者ID:parrotcage,項目名稱:aves,代碼行數:15,代碼來源:ResourceJsonStrategy.php


注:本文中的Zend\View\ViewEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。