LinkHeaderMiddleware should use the same URL as ViewFactory
This way the X-Forwarded-Path header is used to generate the Link header
This commit is contained in:
parent
bfaea0e381
commit
9410d4b49b
3 changed files with 31 additions and 30 deletions
|
@ -57,22 +57,13 @@ class ViewFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Create Smarty view object.
|
||||
* Create a URI suitable for templates.
|
||||
*
|
||||
* @param ContainerInterface $container Slim dependency container
|
||||
* @param Request|null $request PSR-7 request
|
||||
*
|
||||
* @return Smarty
|
||||
* @throws SmartyException
|
||||
* @param Request $request
|
||||
* @return Uri
|
||||
*/
|
||||
public static function create(ContainerInterface $container, Request $request = null): Smarty
|
||||
public static function prepareUri(Request $request): Uri
|
||||
{
|
||||
if (!isset($request)) {
|
||||
$request = $container->get('request');
|
||||
}
|
||||
|
||||
$view = new Smarty($container->get('root_path') . '/templates/');
|
||||
|
||||
/** @var Uri $uri */
|
||||
$uri = $request->getUri();
|
||||
if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) {
|
||||
|
@ -92,11 +83,31 @@ class ViewFactory
|
|||
$uri = $uri->withBasePath($path);
|
||||
}
|
||||
|
||||
return self::cleanBasePath($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Smarty view object.
|
||||
*
|
||||
* @param ContainerInterface $container Slim dependency container
|
||||
* @param Request|null $request PSR-7 request
|
||||
*
|
||||
* @return Smarty
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public static function create(ContainerInterface $container, Request $request = null): Smarty
|
||||
{
|
||||
if (!isset($request)) {
|
||||
$request = $container->get('request');
|
||||
}
|
||||
|
||||
$view = new Smarty($container->get('root_path') . '/templates/');
|
||||
|
||||
$uri = self::prepareUri($request);
|
||||
|
||||
/** @var LocaleManager $localeManager */
|
||||
$localeManager = $container->get('locale');
|
||||
|
||||
$uri = self::cleanBasePath($uri);
|
||||
|
||||
$smartyPlugins = new SmartyPlugins($container->get('router'), $uri->withUserInfo(''));
|
||||
$view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
|
||||
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue