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


PHP EngineInterface::exists方法代碼示例

本文整理匯總了PHP中Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP EngineInterface::exists方法的具體用法?PHP EngineInterface::exists怎麽用?PHP EngineInterface::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Bundle\FrameworkBundle\Templating\EngineInterface的用法示例。


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

示例1: findTemplate

 /**
  * Returns template.
  *
  * @return string
  */
 private function findTemplate()
 {
     if ($this->templateName !== null && $this->templateEngine->exists($this->templateName)) {
         return $this->templateName;
     }
     return 'TwigBundle:Exception:exception_full.html.twig';
 }
開發者ID:Silwereth,項目名稱:sulu,代碼行數:12,代碼來源:PreviewExceptionListener.php

示例2: onKernelView

 /**
  * @param GetResponseForControllerResultEvent $event
  */
 public function onKernelView(GetResponseForControllerResultEvent $event)
 {
     $request = $event->getRequest();
     $attributes = $request->attributes;
     $result = $event->getControllerResult();
     if (!is_array($this->controller) || !is_array($result)) {
         return;
     }
     $view = $attributes->get($this->viewAttribute, null, true);
     if (is_array($view)) {
         $action = basename($this->controller[1], 'Action');
         if (array_key_exists($action, $view)) {
             $view = $view[$action];
         } elseif (!empty($view['_default'])) {
             $view = $view['_default'];
         }
     }
     if ((empty($view) || !is_string($view)) && $this->autoGuess) {
         $view = $this->guessViewName();
     }
     if (!$this->engine->exists($view)) {
         return;
     }
     if ($view) {
         $event->setResponse($this->engine->renderResponse($view, $result));
     }
 }
開發者ID:piotrminkina,項目名稱:frontend-bundle,代碼行數:30,代碼來源:ViewListener.php

示例3: findTemplate

 /**
  * @param EngineInterface $templating
  * @param string          $format
  * @param integer         $code       An HTTP response status code
  * @param Boolean         $debug
  *
  * @return TemplateReference
  */
 protected function findTemplate($templating, $format, $code, $debug)
 {
     $name = $debug ? 'exception' : 'error';
     if ($debug && 'html' == $format) {
         $name = 'exception_full';
     }
     // when not in debug, try to find a template for the specific HTTP status code and format
     if (!$debug) {
         $template = new TemplateReference('TwigBundle', 'Exception', $name . $code, $format, 'twig');
         if ($templating->exists($template)) {
             return $template;
         }
     }
     // try to find a template for the given format
     $template = new TemplateReference('TwigBundle', 'Exception', $name, $format, 'twig');
     if ($templating->exists($template)) {
         return $template;
     }
     // default to a generic HTML exception
     $this->container->get('request')->setRequestFormat('html');
     return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig');
 }
開發者ID:joan16v,項目名稱:symfony2_test,代碼行數:30,代碼來源:ExceptionController.php

示例4: templateExists

 /**
  * @param string $name
  *
  * @return boolean
  */
 public function templateExists($name)
 {
     return $this->templating->exists($name);
 }
開發者ID:knplabs,項目名稱:rad-view-renderer,代碼行數:9,代碼來源:TwigRenderer.php

示例5: createExcelSheet

 /**
  * @param ExportableInterface $adminList
  *
  * @return \PHPExcel_Writer_Excel2007
  *
  * @throws \Exception
  * @throws \PHPExcel_Exception
  */
 public function createExcelSheet(ExportableInterface $adminList)
 {
     $objPHPExcel = new \PHPExcel();
     $objWorksheet = $objPHPExcel->getActiveSheet();
     $number = 1;
     $row = array();
     foreach ($adminList->getExportColumns() as $column) {
         $row[] = $column->getHeader();
     }
     $objWorksheet->fromArray($row, null, 'A' . $number++);
     $iterator = $adminList->getIterator();
     foreach ($iterator as $item) {
         if (array_key_exists(0, $item)) {
             $itemObject = $item[0];
         } else {
             $itemObject = $item;
         }
         $row = array();
         foreach ($adminList->getExportColumns() as $column) {
             $data = $adminList->getStringValue($itemObject, $column->getName());
             if (is_object($data)) {
                 if (!$this->renderer->exists($column->getTemplate())) {
                     throw new \Exception('No export template defined for ' . get_class($data));
                 }
                 $data = $this->renderer->render($column->getTemplate(), array('object' => $data));
             }
             $row[] = $data;
         }
         $objWorksheet->fromArray($row, null, 'A' . $number++);
     }
     $objWriter = new \PHPExcel_Writer_Excel2007($objPHPExcel);
     return $objWriter;
 }
開發者ID:axelvnk,項目名稱:KunstmaanBundlesCMS,代碼行數:41,代碼來源:ExportService.php

示例6: streamExcelSheet

 /**
  * @param ExportableInterface $adminList
  *
  * @return Response
  *
  * @throws \Exception
  */
 public function streamExcelSheet(ExportableInterface $adminList)
 {
     $response = new StreamedResponse();
     $response->setCallback(function () use($adminList) {
         $writer = WriterFactory::create(Type::XLSX);
         $writer->openToBrowser("export.xlsx");
         $row = array();
         foreach ($adminList->getExportColumns() as $column) {
             $row[] = $this->translator->trans($column->getHeader());
         }
         $writer->addRow($row);
         $iterator = $adminList->getIterator();
         $rows = array();
         foreach ($iterator as $item) {
             if (array_key_exists(0, $item)) {
                 $itemObject = $item[0];
             } else {
                 $itemObject = $item;
             }
             $row = array();
             foreach ($adminList->getExportColumns() as $column) {
                 $data = $adminList->getStringValue($itemObject, $column->getName());
                 if (is_object($data)) {
                     if (!$this->renderer->exists($column->getTemplate())) {
                         throw new \Exception('No export template defined for ' . get_class($data));
                     }
                     $data = $this->renderer->render($column->getTemplate(), array('object' => $data));
                 }
                 $row[] = $data;
             }
             $rows[] = $row;
         }
         $writer->addRows($rows);
         $writer->close();
     });
     return $response;
 }
開發者ID:bakie,項目名稱:KunstmaanBundlesCMS,代碼行數:44,代碼來源:ExportService.php


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