Mark Twig variables rewrite_url and is_front_page as deprecated
This commit is contained in:
parent
ec3f7fb626
commit
9a2dd4f078
3 changed files with 12 additions and 6 deletions
|
@ -183,7 +183,6 @@ to use in your theme. Please note that paths (e.g. `{{ base_dir }}`) and URLs
|
|||
is enabled or not
|
||||
* `{{ theme_dir }}` - The path to the currently active theme
|
||||
* `{{ theme_url }}` - The URL to the currently active theme
|
||||
* `{{ rewrite_url }}` - A boolean flag indicating enabled/disabled URL rewriting
|
||||
* `{{ site_title }}` - Shortcut to the site title (see `config/config.php`)
|
||||
* `{{ meta }}` - Contains the meta values from the current page
|
||||
* `{{ meta.title }}`
|
||||
|
@ -213,7 +212,6 @@ to use in your theme. Please note that paths (e.g. `{{ base_dir }}`) and URLs
|
|||
* `{{ prev_page }}` - The data of the previous page (relative to `current_page`)
|
||||
* `{{ current_page }}` - The data of the current page
|
||||
* `{{ next_page }}` - The data of the next page (relative to `current_page`)
|
||||
* `{{ is_front_page }}` - A boolean flag for the front page
|
||||
|
||||
Pages can be used like the following:
|
||||
|
||||
|
|
|
@ -1518,14 +1518,12 @@ class Pico
|
|||
return $this->twigVariables;
|
||||
}
|
||||
|
||||
$frontPage = $this->getConfig('content_dir') . 'index' . $this->getConfig('content_ext');
|
||||
return array(
|
||||
'config' => $this->getConfig(),
|
||||
'base_dir' => rtrim($this->getRootDir(), '/'),
|
||||
'base_url' => rtrim($this->getBaseUrl(), '/'),
|
||||
'theme_dir' => $this->getThemesDir() . $this->getConfig('theme'),
|
||||
'theme_url' => $this->getBaseThemeUrl() . $this->getConfig('theme'),
|
||||
'rewrite_url' => $this->isUrlRewritingEnabled(),
|
||||
'site_title' => $this->getConfig('site_title'),
|
||||
'meta' => $this->meta,
|
||||
'content' => $this->content,
|
||||
|
@ -1533,7 +1531,6 @@ class Pico
|
|||
'prev_page' => $this->previousPage,
|
||||
'current_page' => $this->currentPage,
|
||||
'next_page' => $this->nextPage,
|
||||
'is_front_page' => ($this->requestFile === $frontPage),
|
||||
'version' => static::VERSION
|
||||
);
|
||||
}
|
||||
|
|
|
@ -392,7 +392,8 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||
}
|
||||
|
||||
/**
|
||||
* Triggers the deprecated event before_render($twigVariables, $twig, $templateName)
|
||||
* Adds the deprecated variables rewrite_url and is_front_page, triggers
|
||||
* the deprecated event before_render($twigVariables, $twig, $templateName)
|
||||
*
|
||||
* Please note that the `before_render()` event gets `$templateName` passed
|
||||
* without its file extension. The file extension is later added again.
|
||||
|
@ -401,6 +402,16 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||
*/
|
||||
public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
|
||||
{
|
||||
// rewrite_url and is_front_page are deprecated since Pico 1.1
|
||||
if (!isset($twigVariables['rewrite_url'])) {
|
||||
$twigVariables['rewrite_url'] = $this->isUrlRewritingEnabled();
|
||||
}
|
||||
|
||||
if (!isset($twigVariables['is_front_page'])) {
|
||||
$frontPage = $this->getConfig('content_dir') . 'index' . $this->getConfig('content_ext');
|
||||
$twigVariables['is_front_page'] = ($this->getRequestFile() === $frontPage);
|
||||
}
|
||||
|
||||
// template name contains file extension since Pico 1.0
|
||||
$fileExtension = '';
|
||||
if (($fileExtensionPos = strrpos($templateName, '.')) !== false) {
|
||||
|
|
Loading…
Add table
Reference in a new issue