mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
Merge pull request #3577 from MateBartus/ticket/13800
[ticket/13800] Make router's extension manager dependency optional
This commit is contained in:
commit
a26ab86dc6
6 changed files with 33 additions and 29 deletions
|
@ -15,6 +15,7 @@ imports:
|
||||||
- { resource: services_password.yml }
|
- { resource: services_password.yml }
|
||||||
- { resource: services_profilefield.yml }
|
- { resource: services_profilefield.yml }
|
||||||
- { resource: services_report.yml }
|
- { resource: services_report.yml }
|
||||||
|
- { resource: services_routing.yml }
|
||||||
- { resource: services_text_formatter.yml }
|
- { resource: services_text_formatter.yml }
|
||||||
- { resource: services_twig.yml }
|
- { resource: services_twig.yml }
|
||||||
- { resource: services_user.yml }
|
- { resource: services_user.yml }
|
||||||
|
@ -157,25 +158,6 @@ services:
|
||||||
- null
|
- null
|
||||||
- %core.disable_super_globals%
|
- %core.disable_super_globals%
|
||||||
|
|
||||||
router:
|
|
||||||
class: phpbb\routing\router
|
|
||||||
arguments:
|
|
||||||
- @filesystem
|
|
||||||
- @ext.manager
|
|
||||||
- %core.root_path%
|
|
||||||
- %core.php_ext%
|
|
||||||
- %core.environment%
|
|
||||||
|
|
||||||
router.listener:
|
|
||||||
class: Symfony\Component\HttpKernel\EventListener\RouterListener
|
|
||||||
arguments:
|
|
||||||
- @router
|
|
||||||
- null
|
|
||||||
- null
|
|
||||||
- @request_stack
|
|
||||||
tags:
|
|
||||||
- { name: kernel.event_subscriber }
|
|
||||||
|
|
||||||
# WARNING: The Symfony request does not escape the input and should be used very carefully
|
# WARNING: The Symfony request does not escape the input and should be used very carefully
|
||||||
# prefer the phpbb request (service @request) as possible
|
# prefer the phpbb request (service @request) as possible
|
||||||
symfony_request:
|
symfony_request:
|
||||||
|
|
19
phpBB/config/default/container/services_routing.yml
Normal file
19
phpBB/config/default/container/services_routing.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
services:
|
||||||
|
router:
|
||||||
|
class: phpbb\routing\router
|
||||||
|
arguments:
|
||||||
|
- @filesystem
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
- %core.environment%
|
||||||
|
- @ext.manager
|
||||||
|
|
||||||
|
router.listener:
|
||||||
|
class: Symfony\Component\HttpKernel\EventListener\RouterListener
|
||||||
|
arguments:
|
||||||
|
- @router
|
||||||
|
- null
|
||||||
|
- null
|
||||||
|
- @request_stack
|
||||||
|
tags:
|
||||||
|
- { name: kernel.event_subscriber }
|
|
@ -94,13 +94,14 @@ class router implements RouterInterface
|
||||||
* Construct method
|
* Construct method
|
||||||
*
|
*
|
||||||
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem helper
|
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem helper
|
||||||
* @param manager $extension_manager Extension manager
|
* @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
|
* @param string $environment Name of the current environment
|
||||||
* @param string $environment Name of the current environment
|
* @param manager|null $extension_manager Extension manager
|
||||||
* @param array $routing_files Array of strings containing paths to YAML files holding route information
|
* @param array $routing_files Array of strings containing paths to YAML files
|
||||||
|
* holding route information
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, manager $extension_manager, $phpbb_root_path, $php_ext, $environment, $routing_files = array())
|
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path, $php_ext, $environment, manager $extension_manager = null, $routing_files = array())
|
||||||
{
|
{
|
||||||
$this->filesystem = $filesystem;
|
$this->filesystem = $filesystem;
|
||||||
$this->extension_manager = $extension_manager;
|
$this->extension_manager = $extension_manager;
|
||||||
|
@ -172,7 +173,9 @@ class router implements RouterInterface
|
||||||
{
|
{
|
||||||
if ($this->route_collection == null || empty($this->routing_files))
|
if ($this->route_collection == null || empty($this->routing_files))
|
||||||
{
|
{
|
||||||
$this->find_routing_files($this->extension_manager->all_enabled(false))
|
$this->find_routing_files(
|
||||||
|
($this->extension_manager !== null) ? $this->extension_manager->all_enabled(false) : array()
|
||||||
|
)
|
||||||
->find($this->phpbb_root_path);
|
->find($this->phpbb_root_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
|
$this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager);
|
||||||
$this->router->find_routing_files($this->extension_manager->all_enabled(false));
|
$this->router->find_routing_files($this->extension_manager->all_enabled(false));
|
||||||
$this->router->find(dirname(__FILE__) . '/');
|
$this->router->find(dirname(__FILE__) . '/');
|
||||||
// Set correct current phpBB root path
|
// Set correct current phpBB root path
|
||||||
|
|
|
@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
|
||||||
|
|
||||||
public function test_router_find_files()
|
public function test_router_find_files()
|
||||||
{
|
{
|
||||||
$router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
|
$router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager);
|
||||||
$router->find_routing_files($this->extension_manager->all_enabled(false));
|
$router->find_routing_files($this->extension_manager->all_enabled(false));
|
||||||
$routes = $router->find(__DIR__)->get_routes();
|
$routes = $router->find(__DIR__)->get_routes();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
|
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
|
||||||
|
|
||||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||||
$router = new phpbb_mock_router($filesystem, $manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
|
$router = new phpbb_mock_router($filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager);
|
||||||
$router->find_routing_files($manager->all_enabled(false));
|
$router->find_routing_files($manager->all_enabled(false));
|
||||||
$router->find(dirname(__FILE__) . '/');
|
$router->find(dirname(__FILE__) . '/');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue