[ticket/16314] Reorder controller helper constructor parameters

PHPBB3-16314
This commit is contained in:
Marc Alexander 2020-01-20 17:28:37 +01:00
parent 2bfea20007
commit 8bdad7d73e
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 81 additions and 79 deletions

View file

@ -87,17 +87,18 @@ services:
arguments: arguments:
- '@auth' - '@auth'
- '@cache.driver' - '@cache.driver'
- '@config'
- '@cron.manager' - '@cron.manager'
- '@dbal.conn' - '@dbal.conn'
- '@dispatcher' - '@dispatcher'
- '@language' - '@language'
- '@template'
- '@user'
- '@config'
- '@symfony_request'
- '@request' - '@request'
- '@routing.helper' - '@routing.helper'
- '%core.root_path%%core.adm_relative_path%' - '@symfony_request'
- '@template'
- '@user'
- '%core.root_path%'
- '%core.adm_relative_path%'
- '%core.php_ext%' - '%core.php_ext%'
- '%debug.sql_explain%' - '%debug.sql_explain%'

View file

@ -40,6 +40,9 @@ class helper
/** @var cache_interface */ /** @var cache_interface */
protected $cache; protected $cache;
/** @var config */
protected $config;
/** @var manager */ /** @var manager */
protected $cron_manager; protected $cron_manager;
@ -52,34 +55,20 @@ class helper
/** @var language */ /** @var language */
protected $language; protected $language;
/** /* @var request_interface */
* Template object protected $request;
* @var template
*/
protected $template;
/** /** @var routing_helper */
* User object protected $routing_helper;
* @var user
*/
protected $user;
/**
* config object
* @var config
*/
protected $config;
/* @var symfony_request */ /* @var symfony_request */
protected $symfony_request; protected $symfony_request;
/* @var request_interface */ /** @var template */
protected $request; protected $template;
/** /** @var user */
* @var routing_helper protected $user;
*/
protected $routing_helper;
/** @var string */ /** @var string */
protected $admin_path; protected $admin_path;
@ -95,23 +84,25 @@ class helper
* *
* @param auth $auth Auth object * @param auth $auth Auth object
* @param cache_interface $cache * @param cache_interface $cache
* @param config $config Config object
* @param manager $cron_manager * @param manager $cron_manager
* @param driver_interface $db Dbal object * @param driver_interface $db DBAL object
* @param dispatcher $dispatcher * @param dispatcher $dispatcher
* @param language $language * @param language $language
* @param template $template Template object
* @param user $user User object
* @param config $config Config object
* @param symfony_request $symfony_request Symfony Request object
* @param request_interface $request phpBB request object * @param request_interface $request phpBB request object
* @param routing_helper $routing_helper Helper to generate the routes * @param routing_helper $routing_helper Helper to generate the routes
* @param symfony_request $symfony_request Symfony Request object
* @param template $template Template object
* @param user $user User object
* @param string $root_path phpBB root path
* @param string $admin_path Admin path * @param string $admin_path Admin path
* @param string $php_ext PHP extension * @param string $php_ext PHP extension
* @param bool $sql_explain Flag whether to display sql explain * @param bool $sql_explain Flag whether to display sql explain
*/ */
public function __construct(auth $auth, cache_interface $cache, manager $cron_manager, driver_interface $db, public function __construct(auth $auth, cache_interface $cache, config $config, manager $cron_manager,
dispatcher $dispatcher, language $language, template $template, user $user, config $config, driver_interface $db, dispatcher $dispatcher, language $language,
symfony_request $symfony_request, request_interface $request, routing_helper $routing_helper, request_interface $request, routing_helper $routing_helper,
symfony_request $symfony_request, template $template, user $user, $root_path,
$admin_path, $php_ext, $sql_explain = false) $admin_path, $php_ext, $sql_explain = false)
{ {
$this->auth = $auth; $this->auth = $auth;
@ -126,7 +117,7 @@ class helper
$this->symfony_request = $symfony_request; $this->symfony_request = $symfony_request;
$this->request = $request; $this->request = $request;
$this->routing_helper = $routing_helper; $this->routing_helper = $routing_helper;
$this->admin_path = $admin_path; $this->admin_path = $root_path . $admin_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->sql_explain = $sql_explain; $this->sql_explain = $sql_explain;
} }
@ -166,7 +157,7 @@ class helper
* @param array $params String or array of additional url parameters * @param array $params String or array of additional url parameters
* @param bool $is_amp Is url using & (true) or & (false) * @param bool $is_amp Is url using & (true) or & (false)
* @param string|bool $session_id Possibility to use a custom session id instead of the global one * @param string|bool $session_id Possibility to use a custom session id instead of the global one
* @param bool|string $reference_type The type of reference to be generated (one of the constants) * @param int $reference_type The type of reference to be generated (one of the constants)
* @return string The URL already passed through append_sid() * @return string The URL already passed through append_sid()
*/ */
public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH) public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)

View file

@ -158,7 +158,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->db = $this->new_dbal(); $this->db = $this->new_dbal();
$this->dispatcher = new phpbb_mock_event_dispatcher(); $this->dispatcher = new phpbb_mock_event_dispatcher();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->admin_path = $phpbb_root_path . 'adm/'; $this->admin_path = 'adm/';
$this->php_ext = $phpEx; $this->php_ext = $phpEx;
// Set correct current phpBB root path // Set correct current phpBB root path
@ -208,16 +208,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -267,16 +268,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -326,16 +328,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -385,16 +388,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -444,16 +448,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -503,16 +508,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -559,16 +565,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -618,16 +625,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );
@ -665,16 +673,17 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
$this->auth, $this->auth,
$this->cache, $this->cache,
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'), new \phpbb\cron\manager([], $this->routing_helper, $this->root_path, 'php'),
$this->db, $this->db,
$this->dispatcher, $this->dispatcher,
$this->language, $this->language,
$this->template,
$this->user,
$this->config,
$this->symfony_request,
$this->request, $this->request,
$this->routing_helper, $this->routing_helper,
$this->symfony_request,
$this->template,
$this->user,
$this->root_path,
$this->admin_path, $this->admin_path,
$this->php_ext $this->php_ext
); );

View file

@ -65,17 +65,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$this->helper = new phpbb_mock_controller_helper( $this->helper = new phpbb_mock_controller_helper(
new \phpbb\auth\auth(), new \phpbb\auth\auth(),
new \phpbb\cache\driver\dummy(), new \phpbb\cache\driver\dummy(),
$this->config,
new \phpbb\cron\manager([], $this->routing_helper, '', 'php'), new \phpbb\cron\manager([], $this->routing_helper, '', 'php'),
$db, $db,
new phpbb_mock_event_dispatcher(), new phpbb_mock_event_dispatcher(),
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
$this->template,
$this->user,
$this->config,
$symfony_request,
$request, $request,
$this->routing_helper, $this->routing_helper,
'', $symfony_request,
$this->template,
$this->user,
$phpbb_root_path,
'adm/',
'php' 'php'
); );
$this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher);