mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/12620] Fix rebase
PHPBB3-12620
This commit is contained in:
parent
93f61a4a7d
commit
677b5b2cd4
11 changed files with 188 additions and 168 deletions
|
@ -157,6 +157,7 @@ services:
|
|||
- @ext.manager
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- %core.environment%
|
||||
|
||||
router.listener:
|
||||
class: Symfony\Component\HttpKernel\EventListener\RouterListener
|
||||
|
|
|
@ -41,7 +41,8 @@ class helper
|
|||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\routing\router phpBB router
|
||||
* phpBB router
|
||||
* @var \phpbb\routing\router
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass;
|
||||
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
|
||||
|
||||
class container_builder
|
||||
|
|
|
@ -30,22 +30,37 @@ use phpbb\extension\manager;
|
|||
class router implements RouterInterface
|
||||
{
|
||||
/**
|
||||
* @var manager Extension manager
|
||||
* Extension manager
|
||||
*
|
||||
* @var manager
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* @var string phpBB root path
|
||||
* phpBB root path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string PHP file extensions
|
||||
* PHP file extensions
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* @var array YAML file(s) containing route information
|
||||
* Name of the current environment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* YAML file(s) containing route information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routing_files;
|
||||
|
||||
|
@ -72,40 +87,49 @@ class router implements RouterInterface
|
|||
/**
|
||||
* Construct method
|
||||
*
|
||||
* @param manager $extension_manager The extension manager
|
||||
* @param manager $extension_manager Extension manager
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $php_ext PHP file extension
|
||||
* @param string $environment Name of the current environment
|
||||
* @param array $routing_files Array of strings containing paths to YAML files holding route information
|
||||
*/
|
||||
public function __construct(manager $extension_manager, $phpbb_root_path, $php_ext, $routing_files = array())
|
||||
public function __construct(manager $extension_manager, $phpbb_root_path, $php_ext, $environment, $routing_files = array())
|
||||
{
|
||||
$this->extension_manager = $extension_manager;
|
||||
$this->routing_files = $routing_files;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->environment = $environment;
|
||||
$this->context = new RequestContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the list of routing files
|
||||
*
|
||||
* @param \phpbb\finder $finder
|
||||
* @return router
|
||||
* @param array $paths Array of paths where to look for routing files.
|
||||
* @return null
|
||||
*/
|
||||
public function find_routing_files(\phpbb\finder $finder)
|
||||
public function find_routing_files(array $paths)
|
||||
{
|
||||
if ($this->routing_files === null || empty($this->routing_files))
|
||||
$this->routing_files = array($this->phpbb_root_path . 'config/' . $this->environment . '/routing/environment.yml');
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
// We hardcode the path to the core config directory
|
||||
// because the finder cannot find it
|
||||
$this->routing_files = array_merge($this->routing_files, array('config/routing.yml'), array_keys($finder
|
||||
->directory('/config')
|
||||
->suffix('routing.yml')
|
||||
->find()
|
||||
));
|
||||
if (file_exists($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))
|
||||
{
|
||||
if (file_exists($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'))
|
||||
{
|
||||
$this->routing_files[] = $path . 'config/routing.yml';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +162,7 @@ class router implements RouterInterface
|
|||
{
|
||||
if ($this->route_collection == null || empty($this->routing_files))
|
||||
{
|
||||
$this->find_routing_files($this->extension_manager->get_finder())
|
||||
$this->find_routing_files($this->extension_manager->all_enabled())
|
||||
->find($this->phpbb_root_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
|
|||
)
|
||||
);
|
||||
|
||||
$this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php');
|
||||
$this->router->find_routing_files($finder);
|
||||
$this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
|
||||
$this->router->find_routing_files($this->extension_manager->all_enabled());
|
||||
$this->router->find(dirname(__FILE__) . '/');
|
||||
// Set correct current phpBB root path
|
||||
$this->root_path = $this->get_phpbb_root_path();
|
||||
|
@ -319,7 +319,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
|
|||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
|
||||
}
|
||||
//TODO
|
||||
|
||||
public function helper_url_data_absolute_with_rewrite()
|
||||
{
|
||||
return array(
|
||||
|
|
|
@ -40,8 +40,8 @@ class phpbb_controller_controller_test extends phpbb_test_case
|
|||
|
||||
public function test_router_find_files()
|
||||
{
|
||||
$router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php');
|
||||
$router->find_routing_files($this->extension_manager->get_finder());
|
||||
$router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
|
||||
$router->find_routing_files($this->extension_manager->all_enabled());
|
||||
$routes = $router->find(__DIR__)->get_routes();
|
||||
|
||||
// This will need to be updated if any new routes are defined
|
||||
|
|
|
@ -36,16 +36,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
|||
|
||||
$filesystem = new \phpbb\filesystem();
|
||||
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
|
||||
$finder = new \phpbb\finder(
|
||||
$filesystem,
|
||||
dirname(__FILE__) . '/',
|
||||
new phpbb_mock_cache()
|
||||
);
|
||||
$finder->set_extensions(array_keys($manager->all_enabled()));
|
||||
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
$router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php');
|
||||
$router->find_routing_files($finder);
|
||||
$router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
|
||||
$router->find_routing_files($manager->all_enabled());
|
||||
$router->find(dirname(__FILE__) . '/');
|
||||
|
||||
$request = new phpbb_mock_request();
|
||||
|
|
Loading…
Add table
Reference in a new issue