Use default view variables
This commit is contained in:
parent
110bfc9ff1
commit
6bb577bcce
3 changed files with 27 additions and 33 deletions
|
@ -19,6 +19,23 @@ use SmartyException;
|
|||
*/
|
||||
class ViewFactory
|
||||
{
|
||||
/**
|
||||
* Generate the canonical URL of the current page.
|
||||
*
|
||||
* @param Request $request PSR-7 Request
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
private static function getCanonicalUrl(Request $request)
|
||||
{
|
||||
/** @var Uri $uri */
|
||||
$uri = $request->getUri();
|
||||
|
||||
return $uri->withBasePath('')
|
||||
->withHost('alltubedownload.net')
|
||||
->withScheme('https');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Smarty view object.
|
||||
*
|
||||
|
@ -63,6 +80,10 @@ class ViewFactory
|
|||
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
|
||||
$view->registerPlugin('block', 't', [$localeManager, 'smartyTranslate']);
|
||||
|
||||
$view->offsetSet('canonical', self::getCanonicalUrl($request));
|
||||
$view->offsetSet('locale', $container->get('locale')->getLocale());
|
||||
$view->offsetSet('config', $container->get('config'));
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue