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


PHP TemplateReferenceInterface::getSignature方法代码示例

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


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

示例1: 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 = $template->getSignature();
        $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:nacef,项目名称:symfony,代码行数:40,代码来源:CacheLoader.php

示例2: locate

 /**
  * Returns a full path for a given file.
  *
  * @param TemplateReferenceInterface $template    The template
  * @param string                     $currentPath Unused
  * @param Boolean                    $first       Unused
  *
  * @return string The full path for the file
  *
  * @throws \InvalidArgumentException When file is not found
  */
 public function locate($template, $currentPath = null, $first = true)
 {
     $key = $template->getSignature();
     if (!isset($this->templates[$key])) {
         return parent::locate($template, $currentPath, $first);
     }
     return $this->templates[$key];
 }
开发者ID:rooster,项目名称:symfony,代码行数:19,代码来源:CachedTemplateLocator.php

示例3: locate

 /**
  * Returns a full path for a given file.
  *
  * @param TemplateReferenceInterface $template    The template
  * @param string                     $currentPath Unused
  * @param Boolean                    $first       Unused
  *
  * @return string The full path for the file
  *
  * @throws \InvalidArgumentException When file is not found
  */
 public function locate($template, $currentPath = null, $first = true)
 {
     $key = $template->getSignature();
     if (!isset($this->templates[$key])) {
         throw new \InvalidArgumentException(sprintf('Unable to find template "%s".', json_encode($template)));
     }
     return $this->templates[$key];
 }
开发者ID:noelg,项目名称:symfony-demo,代码行数:19,代码来源:CachedTemplateLocator.php

示例4: 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 file is not found
  */
 public function locate($template, $currentPath = null, $first = true)
 {
     $key = $template->getSignature();
     if (isset($this->cache[$key])) {
         return $this->cache[$key];
     }
     try {
         return $this->cache[$key] = $this->locator->locate($template->getPath(), $this->path);
     } catch (\InvalidArgumentException $e) {
         throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template, $this->path), 0, $e);
     }
 }
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:23,代码来源:TemplateLocator.php

示例5: 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->getSignature();
     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" in "%s".', $template, $this->path), 0, $e);
     }
 }
开发者ID:hellovic,项目名称:symfony,代码行数:27,代码来源:TemplateLocator.php

示例6: load

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

示例7: getCachedTemplatePath

 /**
  * Returns the template path from the cache
  * 
  * @param TemplateReferenceInterface $template The template
  * 
  * @return string|null The path when it is present in the cache, false otherwise
  */
 protected function getCachedTemplatePath(TemplateReferenceInterface $template)
 {
     $key = $template->getSignature();
     return isset($this->templates[$key]) ? $this->templates[$key] : null;
 }
开发者ID:hellovic,项目名称:symfony,代码行数:12,代码来源:CachedTemplateLocator.php


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