Merge pull request #5335 from rubencm/ticket/15765

[ticket/15765] Add debug.url_generator
This commit is contained in:
Marc Alexander 2020-08-30 12:01:51 +02:00 committed by GitHub
commit d94ee3f864
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 10 deletions

View file

@ -7,6 +7,7 @@ services:
- '@routing.delegated_loader' - '@routing.delegated_loader'
- '%core.php_ext%' - '%core.php_ext%'
- '%core.cache_dir%' - '%core.cache_dir%'
- '%debug.url_generator%'
router.listener: router.listener:
class: Symfony\Component\HttpKernel\EventListener\RouterListener class: Symfony\Component\HttpKernel\EventListener\RouterListener

View file

@ -11,6 +11,7 @@ core:
sql_explain: true sql_explain: true
memory: true memory: true
show_errors: true show_errors: true
url_generator: true
twig: twig:
debug: true debug: true

View file

@ -40,6 +40,7 @@ class container_configuration implements ConfigurationInterface
->booleanNode('sql_explain')->defaultValue(false)->end() ->booleanNode('sql_explain')->defaultValue(false)->end()
->booleanNode('memory')->defaultValue(false)->end() ->booleanNode('memory')->defaultValue(false)->end()
->booleanNode('show_errors')->defaultValue(false)->end() ->booleanNode('show_errors')->defaultValue(false)->end()
->booleanNode('url_generator')->defaultValue(false)->end()
->end() ->end()
->end() ->end()
->arrayNode('twig') ->arrayNode('twig')

View file

@ -80,6 +80,11 @@ class router implements RouterInterface
*/ */
protected $cache_dir; protected $cache_dir;
/**
* @var string
*/
protected $debug_url_generator;
/** /**
* Construct method * Construct method
* *
@ -88,8 +93,9 @@ class router implements RouterInterface
* @param LoaderInterface $loader Resources loader * @param LoaderInterface $loader Resources loader
* @param string $php_ext PHP file extension * @param string $php_ext PHP file extension
* @param string $cache_dir phpBB cache directory * @param string $cache_dir phpBB cache directory
* @param string $debug_url_generator Debug url generator
*/ */
public function __construct(ContainerInterface $container, resources_locator_interface $resources_locator, LoaderInterface $loader, $php_ext, $cache_dir) public function __construct(ContainerInterface $container, resources_locator_interface $resources_locator, LoaderInterface $loader, $php_ext, $cache_dir, $debug_url_generator)
{ {
$this->container = $container; $this->container = $container;
$this->resources_locator = $resources_locator; $this->resources_locator = $resources_locator;
@ -97,6 +103,7 @@ class router implements RouterInterface
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->context = new RequestContext(); $this->context = new RequestContext();
$this->cache_dir = $cache_dir; $this->cache_dir = $cache_dir;
$this->debug_url_generator = $debug_url_generator;
} }
/** /**
@ -255,7 +262,7 @@ class router implements RouterInterface
{ {
try try
{ {
$cache = new ConfigCache("{$this->cache_dir}url_generator.{$this->php_ext}", defined('DEBUG')); $cache = new ConfigCache("{$this->cache_dir}url_generator.{$this->php_ext}", $this->debug_url_generator);
if (!$cache->isFresh()) if (!$cache->isFresh())
{ {
$dumper = new PhpGeneratorDumper($this->get_routes()); $dumper = new PhpGeneratorDumper($this->get_routes());

View file

@ -151,7 +151,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
new \phpbb\routing\file_locator(dirname(__FILE__) . '/') new \phpbb\routing\file_locator(dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
$this->router = new phpbb_mock_router($container, $resources_locator, $loader, 'php', dirname(__FILE__) . '/'); $this->router = new phpbb_mock_router($container, $resources_locator, $loader, 'php', dirname(__FILE__) . '/', true);
$this->auth = new \phpbb\auth\auth(); $this->auth = new \phpbb\auth\auth();
$this->cache = new \phpbb\cache\driver\dummy(); $this->cache = new \phpbb\cache\driver\dummy();
$this->db = $this->new_dbal(); $this->db = $this->new_dbal();

View file

@ -48,7 +48,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
new \phpbb\routing\file_locator(dirname(__FILE__) . '/') new \phpbb\routing\file_locator(dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
$router = new phpbb_mock_router($container, $resources_locator, $loader, 'php', dirname(__FILE__) . '/'); $router = new phpbb_mock_router($container, $resources_locator, $loader, 'php', dirname(__FILE__) . '/', true);
$routes = $router->get_routes(); $routes = $router->get_routes();
// This will need to be updated if any new routes are defined // This will need to be updated if any new routes are defined

View file

@ -42,7 +42,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
new \phpbb\routing\file_locator(dirname(__FILE__) . '/') new \phpbb\routing\file_locator(dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager);
$router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, 'php', dirname(__FILE__) . '/'); $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, 'php', dirname(__FILE__) . '/', true);
$request = new phpbb_mock_request(); $request = new phpbb_mock_request();
$request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER); $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);