diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-04-25 18:09:21 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-04-25 18:09:21 +0200 |
commit | 0def8b7d9cb06cd2abf462f18f1404fc119861bd (patch) | |
tree | 8b144548c14a9691681b785ef06040a35ea53128 /phpBB/includes/tree | |
parent | ce07b2776577d1ed3987b38e231a367cfef21db6 (diff) | |
download | forums-0def8b7d9cb06cd2abf462f18f1404fc119861bd.tar forums-0def8b7d9cb06cd2abf462f18f1404fc119861bd.tar.gz forums-0def8b7d9cb06cd2abf462f18f1404fc119861bd.tar.bz2 forums-0def8b7d9cb06cd2abf462f18f1404fc119861bd.tar.xz forums-0def8b7d9cb06cd2abf462f18f1404fc119861bd.zip |
[ticket/11495] Use constructor arguments over properties in implementation
PHPBB3-11495
Diffstat (limited to 'phpBB/includes/tree')
-rw-r--r-- | phpBB/includes/tree/nestedset.php | 31 | ||||
-rw-r--r-- | phpBB/includes/tree/nestedset_forum.php | 38 |
2 files changed, 47 insertions, 22 deletions
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php index 8f73b9181e..245a8165ef 100644 --- a/phpBB/includes/tree/nestedset.php +++ b/phpBB/includes/tree/nestedset.php @@ -56,6 +56,37 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface protected $item_basic_data = array('*'); /** + * Construct + * + * @param phpbb_db_driver $db Database connection + * @param phpbb_lock_db $lock Lock class used to lock the table when moving forums around + * @param string $table_name Table name + * @param string $message_prefix Prefix for the messages thrown by exceptions + * @param string $sql_where Additional SQL restrictions for the queries + * @param array $item_basic_data Array with basic item data that is stored in item_parents + * @param array $columns Array with column names to overwrite + */ + public function __construct(phpbb_db_driver $db, phpbb_lock_db $lock, $table_name, $message_prefix = '', $sql_where = '', $item_basic_data = array(), $columns = array()) + { + $this->db = $db; + $this->lock = $lock; + + $this->table_name = $table_name; + $this->message_prefix = $message_prefix; + $this->sql_where = $sql_where; + $this->item_basic_data = (!empty($item_basic_data)) ? $item_basic_data : array('*'); + + if (!empty($columns)) + { + foreach ($columns as $column => $name) + { + $column_name = 'column_' . $column; + $this->$column_name = $name; + } + } + } + + /** * Returns additional sql where restrictions * * @param string $operator SQL operator that needs to be prepended to sql_where, diff --git a/phpBB/includes/tree/nestedset_forum.php b/phpBB/includes/tree/nestedset_forum.php index 0a66e68915..7dcb12331c 100644 --- a/phpBB/includes/tree/nestedset_forum.php +++ b/phpBB/includes/tree/nestedset_forum.php @@ -18,25 +18,6 @@ if (!defined('IN_PHPBB')) class phpbb_tree_nestedset_forum extends phpbb_tree_nestedset { /** - * Column names in the table - * @var string - */ - protected $column_item_id = 'forum_id'; - protected $column_item_parents = 'forum_parents'; - - /** - * Prefix for the language keys returned by exceptions - * @var string - */ - protected $message_prefix = 'FORUM_NESTEDSET_'; - - /** - * List of item properties to be cached in $item_parents - * @var array - */ - protected $item_basic_data = array('forum_id', 'forum_name', 'forum_type'); - - /** * Construct * * @param phpbb_db_driver $db Database connection @@ -45,8 +26,21 @@ class phpbb_tree_nestedset_forum extends phpbb_tree_nestedset */ public function __construct(phpbb_db_driver $db, phpbb_lock_db $lock, $table_name) { - $this->db = $db; - $this->lock = $lock; - $this->table_name = $table_name; + parent::__construct( + $db, + $lock, + $table_name, + 'FORUM_NESTEDSET_', + '', + array( + 'forum_id', + 'forum_name', + 'forum_type', + ), + array( + 'item_id' => 'forum_id', + 'item_parents' => 'forum_parents', + ) + ); } } |