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


PHP TemplateReferenceInterface::getLogicalName方法代码示例

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


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

示例1: load

 /**
  * Loads a template.
  *
  * @param TemplateReferenceInterface $template A template
  *
  * @return Storage|bool false if the template cannot be loaded, a Storage instance otherwise
  */
 public function load(TemplateReferenceInterface $template)
 {
     $key = hash('sha256', $template->getLogicalName());
     $dir = $this->dir . DIRECTORY_SEPARATOR . substr($key, 0, 2);
     $file = substr($key, 2) . '.tpl';
     $path = $dir . DIRECTORY_SEPARATOR . $file;
     if (is_file($path)) {
         if (null !== $this->logger) {
             $this->logger->debug('Fetching template from cache.', array('name' => $template->get('name')));
         } elseif (null !== $this->debugger) {
             // just for BC, to be removed in 3.0
             $this->debugger->log(sprintf('Fetching template "%s" from cache.', $template->get('name')));
         }
         return new FileStorage($path);
     }
     if (false === ($storage = $this->loader->load($template))) {
         return false;
     }
     $content = $storage->getContent();
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     file_put_contents($path, $content);
     if (null !== $this->logger) {
         $this->logger->debug('Storing template in cache.', array('name' => $template->get('name')));
     } elseif (null !== $this->debugger) {
         // just for BC, to be removed in 3.0
         $this->debugger->log(sprintf('Storing template "%s" in cache.', $template->get('name')));
     }
     return new FileStorage($path);
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:38,代码来源:CacheLoader.php

示例2: load

 /**
  * Loads a template.
  *
  * @param TemplateReferenceInterface $template A template
  *
  * @return Storage|Boolean false if the template cannot be loaded, a Storage instance otherwise
  */
 public function load(TemplateReferenceInterface $template)
 {
     $key = md5($template->getLogicalName());
     $dir = $this->dir . DIRECTORY_SEPARATOR . substr($key, 0, 2);
     $file = substr($key, 2) . '.tpl';
     $path = $dir . DIRECTORY_SEPARATOR . $file;
     if (file_exists($path)) {
         if (null !== $this->debugger) {
             $this->debugger->log(sprintf('Fetching template "%s" from cache', $template->get('name')));
         }
         return new FileStorage($path);
     }
     if (false === ($storage = $this->loader->load($template))) {
         return false;
     }
     $content = $storage->getContent();
     if (!file_exists($dir)) {
         mkdir($dir, 0777, true);
     }
     file_put_contents($path, $content);
     if (null !== $this->debugger) {
         $this->debugger->log(sprintf('Storing template "%s" in cache', $template->get('name')));
     }
     return new FileStorage($path);
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:32,代码来源:CacheLoader.php

示例3: load

 /**
  * Loads a template.
  *
  * @param TemplateReferenceInterface $template A template
  *
  * @return Storage|bool false if the template cannot be loaded, a Storage instance otherwise
  */
 public function load(TemplateReferenceInterface $template)
 {
     $key = md5($template->getLogicalName());
     $dir = $this->dir . DIRECTORY_SEPARATOR . substr($key, 0, 2);
     $file = substr($key, 2) . '.tpl';
     $path = $dir . DIRECTORY_SEPARATOR . $file;
     if (is_file($path)) {
         if (null !== $this->debugger) {
             $this->debugger->log(sprintf('Fetching template "%s" from cache', $template->get('name')));
         }
         return new FileStorage($path);
     }
     if (false === ($storage = $this->loader->load($template))) {
         return false;
     }
     $content = $storage->getContent();
     if (!is_dir($dir) && !@mkdir($dir, 0777, true) && !is_dir($dir)) {
         throw new \RuntimeException(sprintf('Cache Loader was not able to create directory "%s"', $dir));
     }
     file_put_contents($path, $content);
     if (null !== $this->debugger) {
         $this->debugger->log(sprintf('Storing template "%s" in cache', $template->get('name')));
     }
     return new FileStorage($path);
 }
开发者ID:mkemiche,项目名称:Annuaire,代码行数:32,代码来源:CacheLoader.php

示例4: getCacheKey

 /**
  * Returns a full path for a given file.
  *
  * @param TemplateReferenceInterface $template     A template
  *
  * @return string The full path for the file
  */
 protected function getCacheKey($template)
 {
     $name = $template->getLogicalName();
     if ($this->themeManager->getActiveTheme()) {
         $name .= '|' . $this->themeManager->getActiveTheme();
     }
     return $name;
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:15,代码来源:TemplateLocator.php

示例5:

 function it_throws_resource_not_found_exception_if_the_location_found_in_cache_is_null(TemplateLocatorInterface $decoratedTemplateLocator, Cache $cache, TemplateReferenceInterface $template, ThemeInterface $theme)
 {
     $template->getLogicalName()->willReturn('Logical:Name');
     $template->getPath()->willReturn('@Acme/template.html.twig');
     $theme->getName()->willReturn('theme/name');
     $cache->contains('Logical:Name|theme/name')->willReturn(true);
     $cache->fetch('Logical:Name|theme/name')->willReturn(null);
     $decoratedTemplateLocator->locateTemplate(Argument::cetera())->shouldNotBeCalled();
     $this->shouldThrow(ResourceNotFoundException::class)->during('locateTemplate', [$template, $theme]);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:10,代码来源:CachedTemplateLocatorSpec.php

示例6:

 function it_builds_cache_by_warming_up_every_template_and_every_theme_together(TemplateFinderInterface $templateFinder, TemplateLocatorInterface $templateLocator, ThemeRepositoryInterface $themeRepository, Cache $cache, ThemeInterface $theme, TemplateReferenceInterface $firstTemplate, TemplateReferenceInterface $secondTemplate)
 {
     $templateFinder->findAllTemplates()->willReturn([$firstTemplate, $secondTemplate]);
     $themeRepository->findAll()->willReturn([$theme]);
     $theme->getName()->willReturn('theme/name');
     $firstTemplate->getLogicalName()->willReturn('Logical:Name:First');
     $secondTemplate->getLogicalName()->willReturn('Logical:Name:Second');
     $templateLocator->locateTemplate($firstTemplate, $theme)->willReturn('/First/Theme/index.html.twig');
     $templateLocator->locateTemplate($secondTemplate, $theme)->willThrow(ResourceNotFoundException::class);
     $cache->save('Logical:Name:First|theme/name', '/First/Theme/index.html.twig')->shouldBeCalled();
     $cache->save('Logical:Name:Second|theme/name', null)->shouldBeCalled();
     $this->warmUp(null);
 }
开发者ID:Sylius,项目名称:SyliusThemeBundle,代码行数:13,代码来源:TemplatePathsCacheWarmerSpec.php

示例7: locate

 /**
  * Returns a full path for a given file.
  *
  * @param TemplateReferenceInterface $template    A template
  * @param string                     $currentPath Unused
  * @param Boolean                    $first       Unused
  *
  * @return string The full path for the file
  *
  * @throws \InvalidArgumentException When the template is not an instance of TemplateReferenceInterface
  * @throws \InvalidArgumentException When the template file can not be found
  */
 public function locate($template, $currentPath = null, $first = true)
 {
     if (!$template instanceof TemplateReferenceInterface) {
         throw new \InvalidArgumentException("The template must be an instance of TemplateReferenceInterface.");
     }
     $key = $template->getLogicalName();
     if (isset($this->cache[$key])) {
         return $this->cache[$key];
     }
     try {
         return $this->cache[$key] = $this->locator->locate($template->getPath(), $currentPath);
     } catch (\InvalidArgumentException $e) {
         throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e);
     }
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:27,代码来源:TemplateLocator.php

示例8: getCacheKey

 /**
  * Returns a full path for a given file.
  *
  * @param TemplateReferenceInterface $template A template
  *
  * @return string The full path for the file
  */
 protected function getCacheKey($template)
 {
     return $template->getLogicalName();
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:11,代码来源:TemplateLocator.php

示例9: getCacheKey

 /**
  * @param TemplateReferenceInterface $template
  * @param ThemeInterface $theme
  *
  * @return string
  */
 private function getCacheKey(TemplateReferenceInterface $template, ThemeInterface $theme)
 {
     return $template->getLogicalName() . '|' . $theme->getSlug();
 }
开发者ID:benakacha,项目名称:Sylius,代码行数:10,代码来源:CachedTemplateLocator.php

示例10: load

 public function load(TemplateReferenceInterface $template)
 {
     if (isset($this->templates[$template->getLogicalName()])) {
         return new StringStorage($this->templates[$template->getLogicalName()]);
     }
     return false;
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:7,代码来源:PhpEngineTest.php

示例11: load

 public function load(TemplateReferenceInterface $template)
 {
     if (isset($this->templates[$template->getLogicalName()])) {
         $storage = new StringStorage($this->templates[$template->getLogicalName()]);
         return 'string:' . $storage->getContent();
     }
     return false;
 }
开发者ID:noiselabs,项目名称:SmartyBundle,代码行数:8,代码来源:TestCase.php

示例12: getCacheKey

 /**
  * @param TemplateReferenceInterface $template
  * @param ThemeInterface|null $theme
  *
  * @return string
  */
 private function getCacheKey(TemplateReferenceInterface $template, ThemeInterface $theme = null)
 {
     $key = $template->getLogicalName();
     if (null !== $theme) {
         $key .= '|' . $theme->getLogicalName();
     }
     return $key;
 }
开发者ID:liverbool,项目名称:dos-theme-bundle,代码行数:14,代码来源:TemplateLocator.php

示例13: getCacheKey

 /**
  * Returns cache key for a given template
  *
  * @param TemplateReferenceInterface $template
  *
  * @return string
  */
 protected function getCacheKey($template)
 {
     $name = $template->getLogicalName();
     return $name;
 }
开发者ID:Sywooch,项目名称:WellCommerce,代码行数:12,代码来源:TemplateLocator.php

示例14: isFresh

 /**
  * {@inheritdoc}
  */
 public function isFresh(\Symfony\Component\Templating\TemplateReferenceInterface $template, $time)
 {
     return $this->_themeTemplateLocator->isFresh($template->getLogicalName(), $time);
 }
开发者ID:tubepress,项目名称:tubepress,代码行数:7,代码来源:Support.php


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