本文整理汇总了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);
}
示例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];
}
示例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];
}
示例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);
}
}
示例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);
}
}
示例6: load
public function load(TemplateReferenceInterface $template)
{
if (isset($this->templates[$template->getSignature()])) {
return new StringStorage($this->templates[$template->getSignature()]);
}
return false;
}
示例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;
}