From 73fa16f983cd9ddb570edc2dc63bfc4cf06fb067 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 17 Nov 2013 00:38:36 +0100 Subject: [PATCH] [feature/module_services] Move poll module to module services --- config/services.yml | 13 + migrations/v210_beta1.php | 2 +- .../portal_poll.php => modules/poll.php | 232 +++++++++++------- 3 files changed, 160 insertions(+), 87 deletions(-) rename portal/modules/portal_poll.php => modules/poll.php (65%) diff --git a/config/services.yml b/config/services.yml index a5702f6a..5e5b33d7 100644 --- a/config/services.yml +++ b/config/services.yml @@ -205,6 +205,19 @@ services: tags: - { name: board3.module } + board3.module.poll: + class: \board3\portal\modules\poll + arguments: + - @auth + - @config + - @dbal.conn + - @template + - %core.root_path% + - %core.php_ext% + - @user + tags: + - { name: board3.module } + board3.module.search: class: \board3\portal\modules\search arguments: diff --git a/migrations/v210_beta1.php b/migrations/v210_beta1.php index 8a844a01..36d1a9b1 100644 --- a/migrations/v210_beta1.php +++ b/migrations/v210_beta1.php @@ -446,7 +446,7 @@ class v210_beta1 extends \phpbb\db\migration\migration 'module_status' => 1, ), array( - 'module_classname' => 'poll', + 'module_classname' => '\board3\portal\modules\poll', 'module_column' => 2, 'module_order' => 5, 'module_name' => 'PORTAL_POLL', diff --git a/portal/modules/portal_poll.php b/modules/poll.php similarity index 65% rename from portal/modules/portal_poll.php rename to modules/poll.php index 1c4cb909..007ac0eb 100644 --- a/portal/modules/portal_poll.php +++ b/modules/poll.php @@ -1,24 +1,18 @@ auth = $auth; + $this->config = $config; + $this->db = $db; + $this->template = $template; + $this->php_ext = $phpEx; + $this->phpbb_root_path = $phpbb_root_path; + $this->user = $user; + } + + /** + * @inheritdoc + */ public function get_template_center($module_id) { return $this->parse_template($module_id); } + /** + * @inheritdoc + */ public function get_template_side($module_id) { return $this->parse_template($module_id, 'side'); } + /** + * @inheritdoc + */ public function get_template_acp($module_id) { return array( @@ -79,7 +125,7 @@ class portal_poll_module extends \board3\portal\modules\module_base } /** - * API functions + * @inheritdoc */ public function install($module_id) { @@ -91,6 +137,9 @@ class portal_poll_module extends \board3\portal\modules\module_base return true; } + /** + * @inheritdoc + */ public function uninstall($module_id, $db) { $del_config = array( @@ -105,17 +154,23 @@ class portal_poll_module extends \board3\portal\modules\module_base return $db->sql_query($sql); } - // Create forum select box + /** + * Create forum select box + * + * @param mixed $value Value of input + * @param string $key Key name + * @param int $module_id Module ID + * + * @return null + */ public function select_forums($value, $key, $module_id) { - global $user, $config; - $forum_list = make_forum_select(false, false, true, true, true, false, true); $selected = array(); - if(isset($config[$key]) && strlen($config[$key]) > 0) + if(isset($this->config[$key]) && strlen($this->config[$key]) > 0) { - $selected = explode(',', $config[$key]); + $selected = explode(',', $this->config[$key]); } // Build forum options $s_forum_options = '