1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

Merge pull request #3303 from Nicofuma/ticket/13513

[ticket/13513] Use paths relative to the phpBB root in the router
This commit is contained in:
Marc Alexander
2015-02-26 13:41:51 +01:00
5 changed files with 21 additions and 16 deletions

View File

@@ -464,15 +464,17 @@ class manager
* All enabled and disabled extensions are considered configured. A purged
* extension that is no longer in the database is not configured.
*
* @param bool $phpbb_relative Whether the path should be relative to phpbb root
*
* @return array An array with extension names as keys and and the
* database stored extension information as values
*/
public function all_configured()
public function all_configured($phpbb_relative = true)
{
$configured = array();
foreach ($this->extensions as $name => $data)
{
$data['ext_path'] = $this->phpbb_root_path . $data['ext_path'];
$data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
$configured[$name] = $data;
}
return $configured;
@@ -480,18 +482,19 @@ class manager
/**
* Retrieves all enabled extensions.
* @param bool $phpbb_relative Whether the path should be relative to phpbb root
*
* @return array An array with extension names as keys and and the
* database stored extension information as values
*/
public function all_enabled()
public function all_enabled($phpbb_relative = true)
{
$enabled = array();
foreach ($this->extensions as $name => $data)
{
if ($data['ext_active'])
{
$enabled[$name] = $this->phpbb_root_path . $data['ext_path'];
$enabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
}
}
return $enabled;
@@ -500,17 +503,19 @@ class manager
/**
* Retrieves all disabled extensions.
*
* @param bool $phpbb_relative Whether the path should be relative to phpbb root
*
* @return array An array with extension names as keys and and the
* database stored extension information as values
*/
public function all_disabled()
public function all_disabled($phpbb_relative = true)
{
$disabled = array();
foreach ($this->extensions as $name => $data)
{
if (!$data['ext_active'])
{
$disabled[$name] = $this->phpbb_root_path . $data['ext_path'];
$disabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
}
}
return $disabled;

View File

@@ -107,25 +107,25 @@ class router implements RouterInterface
/**
* Find the list of routing files
*
* @param array $paths Array of paths where to look for routing files.
* @param array $paths Array of paths where to look for routing files (they must be relative to the phpBB root path).
* @return router
*/
public function find_routing_files(array $paths)
{
$this->routing_files = array($this->phpbb_root_path . 'config/' . $this->environment . '/routing/environment.yml');
$this->routing_files = array('config/' . $this->environment . '/routing/environment.yml');
foreach ($paths as $path)
{
if (file_exists($path . 'config/' . $this->environment . '/routing/environment.yml'))
if (file_exists($this->phpbb_root_path . $path . 'config/' . $this->environment . '/routing/environment.yml'))
{
$this->routing_files[] = $path . 'config/' . $this->environment . '/routing/environment.yml';
}
else if (!is_dir($path . 'config/' . $this->environment))
else if (!is_dir($this->phpbb_root_path . $path . 'config/' . $this->environment))
{
if (file_exists($path . 'config/default/routing/environment.yml'))
if (file_exists($this->phpbb_root_path . $path . 'config/default/routing/environment.yml'))
{
$this->routing_files[] = $path . 'config/default/routing/environment.yml';
}
else if (!is_dir($path . 'config/default/routing') && file_exists($path . 'config/routing.yml'))
else if (!is_dir($this->phpbb_root_path . $path . 'config/default/routing') && file_exists($this->phpbb_root_path . $path . 'config/routing.yml'))
{
$this->routing_files[] = $path . 'config/routing.yml';
}
@@ -165,7 +165,7 @@ class router implements RouterInterface
{
if ($this->route_collection == null || empty($this->routing_files))
{
$this->find_routing_files($this->extension_manager->all_enabled())
$this->find_routing_files($this->extension_manager->all_enabled(false))
->find($this->phpbb_root_path);
}