本文整理汇总了PHP中Symfony\Component\Templating\EngineInterface::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface::exists方法的具体用法?PHP EngineInterface::exists怎么用?PHP EngineInterface::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Templating\EngineInterface
的用法示例。
在下文中一共展示了EngineInterface::exists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadResourceFromTheme
/**
* Tries to load the resource for a block from a theme.
*
* @param string $cacheKey The cache key for storing the resource.
* @param string $blockName The name of the block to load a resource for.
* @param mixed $theme The theme to load the block from.
*
* @return bool True if the resource could be loaded, false otherwise.
*/
protected function loadResourceFromTheme($cacheKey, $blockName, $theme)
{
if ($this->engine->exists($templateName = $theme . '/' . $blockName . '.html.php')) {
$this->resources[$cacheKey][$blockName] = $templateName;
return true;
}
return false;
}
示例2: getTemplatePath
/**
* Locates the applicable template and returns its path.
* @return string The template path.
*/
protected function getTemplatePath()
{
$paths = ['@custom_webindex_templates/' . self::DEFAULT_TEMPLATE_NAME];
foreach ($paths as $path) {
if ($this->templatingEngine->exists($path)) {
return $path;
}
}
return 'IliosWebBundle:WebIndex:' . self::DEFAULT_TEMPLATE_NAME;
}
示例3: findTemplate
/**
* Finds the template in all the bundles.
*
* @param string $templatePath The template to search.
*
* @return bool|string The string found or false if not found
*/
protected function findTemplate($templatePath)
{
foreach ($this->bundles as $bundleName) {
$templateName = "{$bundleName}:{$templatePath}";
if ($this->engine->exists($templateName)) {
return $templateName;
}
}
return false;
}
示例4: formatColumn
/**
* @param $element
* @param $columnName
* @return string
* @throws Exception
*/
private function formatColumn($element, $columnName)
{
$nameArray = explode('.', $columnName);
$columnName = $nameArray[0];
$view = $this->repository->getTemplatesPath() . $columnName . '.html.twig';
if ($this->templating->exists($view)) {
return $this->templating->render($view, ['element' => $element]);
}
if (method_exists($element, $columnName)) {
return $element->{$columnName}();
}
$getter = 'get' . ucfirst($columnName);
if (!method_exists($element, $getter)) {
throw new Exception($this->translator->trans(self::ERROR_NO_ELEMENT_RENDER_INFO) . ': ' . $columnName);
}
$result = $element->{$getter}();
if (!isset($nameArray[1])) {
if ($result instanceof \DateTime) {
return $result->format('d.m.Y');
}
return $result;
}
unset($nameArray[0]);
return $result ? $this->formatColumn($result, implode('.', $nameArray)) : '';
}
示例5: src
/**
* Gets the RequireJS src
*
* @return string Returns a string that represents the RequireJS src
*/
public function src()
{
if ($this->engine->exists($this->requireJsSrc) && $this->engine->supports($this->requireJsSrc)) {
return $this->engine->render($this->requireJsSrc);
}
return $this->requireJsSrc;
}
示例6: getTemplatePath
/**
* Locates the applicable message template for a given school and returns its path.
* @param SchoolInterface $school
* @return string The template path.
*/
protected function getTemplatePath(SchoolInterface $school)
{
$paths = ['@custom_email_templates/' . basename($school->getTemplatePrefix() . '_' . self::DEFAULT_TEMPLATE_NAME), '@custom_email_templates/' . self::DEFAULT_TEMPLATE_NAME];
foreach ($paths as $path) {
if ($this->templatingEngine->exists($path)) {
return $path;
}
}
return 'IliosCoreBundle:Email:' . self::DEFAULT_TEMPLATE_NAME;
}
示例7: locateTemplate
/**
* Search for the template in every specified bundle
*
* @return string Found existing template name
*/
private function locateTemplate()
{
foreach ($this->bundles as $bundleName) {
$templateName = "{$bundleName}:{$this->templatePath}";
if ($this->engine->exists($templateName)) {
return $templateName;
}
}
throw new RuntimeException(sprintf('Template "%s" not found', $this->templatePath));
}
示例8: src
/**
* Gets the RequireJS src
*
* @return string Returns a string that represents the RequireJS src
*/
public function src()
{
try {
if ($this->engine->exists($this->requireJsSrc) && $this->engine->supports($this->requireJsSrc)) {
return $this->engine->render($this->requireJsSrc);
}
} catch (\InvalidArgumentException $err) {
}
return $this->requireJsSrc;
}
示例9: getTemplate
/**
* Returns export template for given format like XLIFF1.2.
*
* @param $format
*
* @return string
*
* @throws \Exception
*/
protected function getTemplate($format)
{
if (!isset($this->formatFilePaths[$format])) {
throw new \Exception(sprintf('No format "%s" configured for webspace export', $format));
}
$templatePath = $this->formatFilePaths[$format];
if (!$this->templating->exists($templatePath)) {
throw new \Exception(sprintf('No template file "%s" found for webspace export', $format));
}
return $templatePath;
}
示例10: renderLocationEmbed
public function renderLocationEmbed($locationId, $viewType, array $parameters, $isInline)
{
$isDenied = false;
try {
$location = $this->checkLocation($locationId);
if ($location->invisible) {
if (isset($this->logger)) {
$this->logger->error("Could not render embedded resource: Location #{$locationId} is not visible");
}
return null;
}
} catch (AccessDeniedException $e) {
if (isset($this->logger)) {
$this->logger->error("Could not render embedded resource: access denied to embed Location #{$locationId}");
}
$isDenied = true;
} catch (Exception $e) {
if ($e instanceof NotFoundHttpException || $e instanceof NotFoundException) {
if (isset($this->logger)) {
$this->logger->error("Could not render embedded resource: Location #{$locationId} not found");
}
return null;
} else {
throw $e;
}
}
$templateName = $this->getEmbedTemplateName(static::RESOURCE_TYPE_LOCATION, $isInline, $isDenied);
if ($templateName === null) {
$this->logger->error('Could not render embedded resource: no template configured');
return null;
}
if (!$this->templateEngine->exists($templateName)) {
if (isset($this->logger)) {
$this->logger->error("Could not render embedded resource: template '{$templateName}' does not exists");
}
return null;
}
return $this->render($templateName, $parameters);
}
示例11: getTemplate
/**
* @param string $template
* @param array $parameters
*
* @return null|string
*/
protected function getTemplate($template, array $parameters = [])
{
return $this->templating->exists($template) ? $this->templating->render($template, $parameters) : null;
}
示例12: exists
public function exists($name)
{
return $this->engine->exists($name);
}