mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/13034] Update the base url to move to the root dir
PHPBB3-13034
This commit is contained in:
parent
06f42f433b
commit
68ad7685bc
2 changed files with 19 additions and 2 deletions
|
@ -100,6 +100,7 @@ services:
|
||||||
- @controller.provider
|
- @controller.provider
|
||||||
- @ext.manager
|
- @ext.manager
|
||||||
- @symfony_request
|
- @symfony_request
|
||||||
|
- @filesystem
|
||||||
- %core.root_path%
|
- %core.root_path%
|
||||||
- %core.php_ext%
|
- %core.php_ext%
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,11 @@ class helper
|
||||||
/* @var \phpbb\symfony_request */
|
/* @var \phpbb\symfony_request */
|
||||||
protected $symfony_request;
|
protected $symfony_request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \phpbb\filesystem The filesystem object
|
||||||
|
*/
|
||||||
|
protected $filesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phpBB root path
|
* phpBB root path
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -64,15 +69,17 @@ class helper
|
||||||
* @param \phpbb\controller\provider $provider Path provider
|
* @param \phpbb\controller\provider $provider Path provider
|
||||||
* @param \phpbb\extension\manager $manager Extension manager object
|
* @param \phpbb\extension\manager $manager Extension manager object
|
||||||
* @param \phpbb\symfony_request $symfony_request Symfony Request object
|
* @param \phpbb\symfony_request $symfony_request Symfony Request object
|
||||||
|
* @param \phpbb\filesystem $filesystem The filesystem object
|
||||||
* @param string $phpbb_root_path phpBB root path
|
* @param string $phpbb_root_path phpBB root path
|
||||||
* @param string $php_ext PHP file extension
|
* @param string $php_ext PHP file extension
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext)
|
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->symfony_request = $symfony_request;
|
$this->symfony_request = $symfony_request;
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
$this->php_ext = $php_ext;
|
||||||
$provider->find_routing_files($manager->get_finder());
|
$provider->find_routing_files($manager->get_finder());
|
||||||
|
@ -126,8 +133,17 @@ class helper
|
||||||
$script_name = $this->symfony_request->getScriptName();
|
$script_name = $this->symfony_request->getScriptName();
|
||||||
$page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
|
$page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
|
||||||
|
|
||||||
|
$base_url = $context->getBaseUrl();
|
||||||
|
|
||||||
// If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
|
// If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
|
||||||
$context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl()));
|
$base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);
|
||||||
|
|
||||||
|
// We need to update the base url to move to the directory of the app.php file.
|
||||||
|
$base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url);
|
||||||
|
|
||||||
|
$base_url = $this->filesystem->clean_path($base_url);
|
||||||
|
|
||||||
|
$context->setBaseUrl($base_url);
|
||||||
|
|
||||||
$url_generator = new UrlGenerator($this->route_collection, $context);
|
$url_generator = new UrlGenerator($this->route_collection, $context);
|
||||||
$route_url = $url_generator->generate($route, $params);
|
$route_url = $url_generator->generate($route, $params);
|
||||||
|
|
Loading…
Add table
Reference in a new issue