本文整理匯總了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';
}
示例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));
}
}
示例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');
}
示例4: templateExists
/**
* @param string $name
*
* @return boolean
*/
public function templateExists($name)
{
return $this->templating->exists($name);
}
示例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;
}
示例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;
}