diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-05-20 00:23:42 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-05-20 20:11:52 +0200 |
commit | 077051fef56f0d9b504a2593dc84a3d05ef02e18 (patch) | |
tree | a3c992ee0fb50146bf9e3c31c870cce67a2cc12f | |
parent | 6dcc14bc5824b3ff74a3cd3acd574ae5e530d1c3 (diff) | |
download | forums-077051fef56f0d9b504a2593dc84a3d05ef02e18.tar forums-077051fef56f0d9b504a2593dc84a3d05ef02e18.tar.gz forums-077051fef56f0d9b504a2593dc84a3d05ef02e18.tar.bz2 forums-077051fef56f0d9b504a2593dc84a3d05ef02e18.tar.xz forums-077051fef56f0d9b504a2593dc84a3d05ef02e18.zip |
[ticket/13844] Add events
PHPBB3-13844
-rw-r--r-- | phpBB/config/default/container/services_help.yml | 5 | ||||
-rw-r--r-- | phpBB/phpbb/help/controller/controller.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/help/manager.php | 61 | ||||
-rw-r--r-- | tests/help/manager_test.php | 7 |
4 files changed, 63 insertions, 17 deletions
diff --git a/phpBB/config/default/container/services_help.yml b/phpBB/config/default/container/services_help.yml index 29523ffb27..8b9d497945 100644 --- a/phpBB/config/default/container/services_help.yml +++ b/phpBB/config/default/container/services_help.yml @@ -2,14 +2,14 @@ services: phpbb.help.manager: class: phpbb\help\manager arguments: - - @template + - @dispatcher - @language + - @template phpbb.help.controller.bbcode: class: phpbb\help\controller\bbcode arguments: - @controller.helper - - @dispatcher - @phpbb.help.manager - @template - @language @@ -20,7 +20,6 @@ services: class: phpbb\help\controller\faq arguments: - @controller.helper - - @dispatcher - @phpbb.help.manager - @template - @language diff --git a/phpBB/phpbb/help/controller/controller.php b/phpBB/phpbb/help/controller/controller.php index 743a9c7fde..29494205a9 100644 --- a/phpBB/phpbb/help/controller/controller.php +++ b/phpBB/phpbb/help/controller/controller.php @@ -21,9 +21,6 @@ abstract class controller /** @var \phpbb\controller\helper */ protected $helper; - /** @var \phpbb\event\dispatcher_interface */ - protected $dispatcher; - /** @var \phpbb\help\manager */ protected $manager; @@ -43,17 +40,15 @@ abstract class controller * Constructor * * @param \phpbb\controller\helper $helper - * @param \phpbb\event\dispatcher_interface $dispatcher * @param \phpbb\help\manager $manager * @param \phpbb\template\template $template * @param \phpbb\language\language $language * @param string $root_path * @param string $php_ext */ - public function __construct(\phpbb\controller\helper $helper, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\help\manager $manager, \phpbb\template\template $template, \phpbb\language\language $language, $root_path, $php_ext) + public function __construct(\phpbb\controller\helper $helper, \phpbb\help\manager $manager, \phpbb\template\template $template, \phpbb\language\language $language, $root_path, $php_ext) { $this->helper = $helper; - $this->dispatcher = $dispatcher; $this->manager = $manager; $this->template = $template; $this->language = $language; diff --git a/phpBB/phpbb/help/manager.php b/phpBB/phpbb/help/manager.php index a7320563a8..d6991c0733 100644 --- a/phpBB/phpbb/help/manager.php +++ b/phpBB/phpbb/help/manager.php @@ -18,25 +18,30 @@ namespace phpbb\help; */ class manager { - /** @var \phpbb\template\template */ - protected $template; + /** @var \phpbb\event\dispatcher */ + protected $dispatcher; /** @var \phpbb\language\language */ protected $language; + /** @var \phpbb\template\template */ + protected $template; + /** @var bool */ protected $switched_column; /** * Constructor * - * @param \phpbb\template\template $template + * @param \phpbb\event\dispatcher $dispatcher * @param \phpbb\language\language $language + * @param \phpbb\template\template $template */ - public function __construct(\phpbb\template\template $template, \phpbb\language\language $language) + public function __construct(\phpbb\event\dispatcher $dispatcher, \phpbb\language\language $language, \phpbb\template\template $template) { - $this->template = $template; + $this->dispatcher = $dispatcher; $this->language = $language; + $this->template = $template; } /** @@ -47,6 +52,18 @@ class manager */ public function add_block($block_name, $switch_column = false, $questions = array()) { + /** + * You can use this event to add a block before the current one. + * + * @event core.help_manager_add_block_before + * @var string block_name Language key of the block headline + * @var bool switch_column Should we switch the menu column before this headline + * @var array questions Array with questions + * @since 3.2.0-a1 + */ + $vars = array('block_name', 'switch_column', 'questions'); + extract($this->dispatcher->trigger_event('core.help_manager_add_block_before', compact($vars))); + $this->template->assign_block_vars('faq_block', array( 'BLOCK_TITLE' => $this->language->lang($block_name), 'SWITCH_COLUMN' => !$this->switched_column && $switch_column, @@ -58,6 +75,18 @@ class manager } $this->switched_column = $this->switched_column || $switch_column; + + /** + * You can use this event to add a block after the current one. + * + * @event core.help_manager_add_block_after + * @var string block_name Language key of the block headline + * @var bool switch_column Should we switch the menu column before this headline + * @var array questions Array with questions + * @since 3.2.0-a1 + */ + $vars = array('block_name', 'switch_column', 'questions'); + extract($this->dispatcher->trigger_event('core.help_manager_add_block_after', compact($vars))); } /** @@ -68,10 +97,32 @@ class manager */ public function add_question($question, $answer) { + /** + * You can use this event to add a question before the current one. + * + * @event core.help_manager_add_question_before + * @var string question Language key of the question + * @var string answer Language key of the answer + * @since 3.2.0-a1 + */ + $vars = array('question', 'answer'); + extract($this->dispatcher->trigger_event('core.help_manager_add_question_before', compact($vars))); + $this->template->assign_block_vars('faq_block.faq_row', array( 'FAQ_QUESTION' => $this->language->lang($question), 'FAQ_ANSWER' => $this->language->lang($answer), )); + + /** + * You can use this event to add a question after the current one. + * + * @event core.help_manager_add_question_after + * @var string question Language key of the question + * @var string answer Language key of the answer + * @since 3.2.0-a1 + */ + $vars = array('question', 'answer'); + extract($this->dispatcher->trigger_event('core.help_manager_add_question_after', compact($vars))); } /** diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php index aaf63194fa..68534d9a32 100644 --- a/tests/help/manager_test.php +++ b/tests/help/manager_test.php @@ -11,7 +11,7 @@ * */ -class phpbb_language_test extends phpbb_test_case +class phpbb_help_manager_test extends phpbb_test_case { /** @var \phpbb\help\manager */ protected $manager; @@ -30,8 +30,9 @@ class phpbb_language_test extends phpbb_test_case ->getMock(); $this->manager = new \phpbb\help\manager( - $this->template, - $this->language + new \phpbb_mock_event_dispatcher(), + $this->language, + $this->template ); } |