Skip to content

Commit 291012c

Browse files
committed
Revert manager just use multiple classes
1 parent ac6e9c8 commit 291012c

9 files changed

Lines changed: 224 additions & 550 deletions

File tree

config/services.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- '@auth'
99
- '@config'
1010
- '@controller.helper'
11-
- '@phpbb.ideas.manager'
11+
- '@phpbb.ideas.idea'
1212
- '@language'
1313
- '@phpbb.ideas.linkhelper'
1414
- '@template'
@@ -37,7 +37,6 @@ services:
3737
- '@auth'
3838
- '@config'
3939
- '@controller.helper'
40-
- '@phpbb.ideas.manager'
4140
- '@language'
4241
- '@phpbb.ideas.linkhelper'
4342
- '@pagination'
@@ -50,10 +49,14 @@ services:
5049
phpbb.ideas.index_controller:
5150
class: phpbb\ideas\controller\index_controller
5251
parent: phpbb.ideas.controller.base
52+
calls:
53+
- [get_entity, ['@phpbb.ideas.ideas']]
5354

5455
phpbb.ideas.list_controller:
5556
class: phpbb\ideas\controller\list_controller
5657
parent: phpbb.ideas.controller.base
58+
calls:
59+
- [get_entity, ['@phpbb.ideas.ideas']]
5760

5861
phpbb.ideas.post_controller:
5962
class: phpbb\ideas\controller\post_controller
@@ -62,19 +65,16 @@ services:
6265
phpbb.ideas.idea_controller:
6366
class: phpbb\ideas\controller\idea_controller
6467
parent: phpbb.ideas.controller.base
68+
calls:
69+
- [get_entity, ['@phpbb.ideas.idea']]
6570

6671
phpbb.ideas.livesearch_controller:
6772
class: phpbb\ideas\controller\livesearch_controller
6873
parent: phpbb.ideas.controller.base
74+
calls:
75+
- [get_entity, ['@phpbb.ideas.ideas']]
6976

7077
# ----- Idea Factory Classes -----
71-
phpbb.ideas.manager:
72-
class: phpbb\ideas\factory\manager
73-
arguments:
74-
- '@phpbb.ideas.idea'
75-
- '@phpbb.ideas.ideas'
76-
- '@phpbb.ideas.vote'
77-
7878
phpbb.ideas.base:
7979
class: phpbb\ideas\factory\ideas
8080
arguments:
@@ -95,12 +95,6 @@ services:
9595
phpbb.ideas.idea:
9696
class: phpbb\ideas\factory\idea
9797
parent: phpbb.ideas.base
98-
arguments:
99-
- '@phpbb.ideas.vote'
100-
101-
phpbb.ideas.vote:
102-
class: phpbb\ideas\factory\vote
103-
parent: phpbb.ideas.base
10498

10599
phpbb.ideas.linkhelper:
106100
class: phpbb\ideas\factory\linkhelper
@@ -119,7 +113,7 @@ services:
119113
class: phpbb\ideas\cron\prune_orphaned_ideas
120114
arguments:
121115
- '@config'
122-
- '@phpbb.ideas.manager'
116+
- '@phpbb.ideas.ideas'
123117
calls:
124118
- [set_name, [cron.task.prune_orphaned_ideas]]
125119
tags:

controller/base.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use phpbb\config\config;
1515
use phpbb\controller\helper;
1616
use phpbb\ideas\ext;
17-
use phpbb\ideas\factory\manager as ideas;
1817
use phpbb\ideas\factory\linkhelper;
1918
use phpbb\language\language;
2019
use phpbb\pagination;
@@ -33,7 +32,7 @@ abstract class base
3332
/* @var helper */
3433
protected $helper;
3534

36-
/* @var ideas */
35+
/* @var \phpbb\ideas\factory\ideas|\phpbb\ideas\factory\idea */
3736
protected $ideas;
3837

3938
/** @var language */
@@ -64,7 +63,6 @@ abstract class base
6463
* @param auth $auth
6564
* @param config $config
6665
* @param helper $helper
67-
* @param ideas $ideas
6866
* @param language $language
6967
* @param linkhelper $link_helper
7068
* @param pagination $pagination
@@ -74,12 +72,11 @@ abstract class base
7472
* @param string $root_path
7573
* @param string $php_ext
7674
*/
77-
public function __construct(auth $auth, config $config, helper $helper, ideas $ideas, language $language, linkhelper $link_helper, pagination $pagination, request $request, template $template, user $user, $root_path, $php_ext)
75+
public function __construct(auth $auth, config $config, helper $helper, language $language, linkhelper $link_helper, pagination $pagination, request $request, template $template, user $user, $root_path, $php_ext)
7876
{
7977
$this->auth = $auth;
8078
$this->config = $config;
8179
$this->helper = $helper;
82-
$this->ideas = $ideas;
8380
$this->language = $language;
8481
$this->link_helper = $link_helper;
8582
$this->pagination = $pagination;
@@ -92,6 +89,16 @@ public function __construct(auth $auth, config $config, helper $helper, ideas $i
9289
$this->language->add_lang('common', 'phpbb/ideas');
9390
}
9491

92+
/**
93+
* Set the Ideas entity
94+
*
95+
* @param string $entity
96+
*/
97+
public function get_entity($entity)
98+
{
99+
$this->ideas = $entity;
100+
}
101+
95102
/**
96103
* Check if Ideas is properly configured after installation
97104
* Ideas is available only after forum settings have been set in ACP

controller/livesearch_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function title_search()
2424
{
2525
$title_chars = $this->request->variable('duplicateeditinput', '', true);
2626

27-
$matches = $this->ideas->ideas_title_livesearch($title_chars, 10);
27+
$matches = $this->ideas->livesearch($title_chars, 10);
2828

2929
return new \Symfony\Component\HttpFoundation\JsonResponse([
3030
'keyword' => $title_chars,

cron/prune_orphaned_ideas.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ class prune_orphaned_ideas extends \phpbb\cron\task\base
1818
/** @var \phpbb\config\config */
1919
protected $config;
2020

21-
/** @var \phpbb\ideas\factory\manager */
21+
/** @var \phpbb\ideas\factory\ideas */
2222
protected $ideas;
2323

2424
/**
2525
* Constructor
2626
*
27-
* @param \phpbb\config\config $config Config object
28-
* @param \phpbb\ideas\factory\manager $ideas Ideas factory object
27+
* @param \phpbb\config\config $config Config object
28+
* @param \phpbb\ideas\factory\ideas $ideas Ideas factory object
2929
* @access public
3030
*/
31-
public function __construct(\phpbb\config\config $config, \phpbb\ideas\factory\manager $ideas)
31+
public function __construct(\phpbb\config\config $config, \phpbb\ideas\factory\ideas $ideas)
3232
{
3333
$this->config = $config;
3434
$this->ideas = $ideas;

event/listener.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use phpbb\config\config;
1515
use phpbb\controller\helper;
1616
use phpbb\ideas\ext;
17-
use phpbb\ideas\factory\manager as ideas;
17+
use phpbb\ideas\factory\idea;
1818
use phpbb\ideas\factory\linkhelper;
1919
use phpbb\language\language;
2020
use phpbb\template\template;
@@ -32,8 +32,8 @@ class listener implements EventSubscriberInterface
3232
/* @var helper */
3333
protected $helper;
3434

35-
/* @var ideas */
36-
protected $ideas;
35+
/* @var idea */
36+
protected $idea;
3737

3838
/** @var language */
3939
protected $language;
@@ -54,19 +54,19 @@ class listener implements EventSubscriberInterface
5454
* @param \phpbb\auth\auth $auth
5555
* @param \phpbb\config\config $config
5656
* @param \phpbb\controller\helper $helper
57-
* @param \phpbb\ideas\factory\manager $ideas
57+
* @param \phpbb\ideas\factory\idea $idea
5858
* @param \phpbb\language\language $language
5959
* @param \phpbb\ideas\factory\linkhelper $link_helper
6060
* @param \phpbb\template\template $template
6161
* @param \phpbb\user $user
6262
* @param string $php_ext
6363
*/
64-
public function __construct(auth $auth, config $config, helper $helper, ideas $ideas, language $language, linkhelper $link_helper, template $template, user $user, $php_ext)
64+
public function __construct(auth $auth, config $config, helper $helper, idea $idea, language $language, linkhelper $link_helper, template $template, user $user, $php_ext)
6565
{
6666
$this->auth = $auth;
6767
$this->config = $config;
6868
$this->helper = $helper;
69-
$this->ideas = $ideas;
69+
$this->idea = $idea;
7070
$this->language = $language;
7171
$this->link_helper = $link_helper;
7272
$this->template = $template;
@@ -143,7 +143,7 @@ public function show_idea($event)
143143
return;
144144
}
145145

146-
$idea = $this->ideas->get_idea_by_topic_id($event['topic_data']['topic_id']);
146+
$idea = $this->idea->get_idea_by_topic_id($event['topic_data']['topic_id']);
147147

148148
if (!$idea)
149149
{
@@ -174,7 +174,7 @@ public function show_idea($event)
174174
$s_voted_up = $s_voted_down = false;
175175
if ($idea['idea_votes_up'] || $idea['idea_votes_down'])
176176
{
177-
$votes = $this->ideas->get_voters($idea['idea_id']);
177+
$votes = $this->idea->get_voters($idea['idea_id']);
178178

179179
foreach ($votes as $vote)
180180
{
@@ -198,9 +198,9 @@ public function show_idea($event)
198198
'IDEA_VOTES_DOWN' => $idea['idea_votes_down'],
199199
'IDEA_POINTS' => $points,
200200
'IDEA_STATUS_ID' => $idea['idea_status'],
201-
'IDEA_STATUS_NAME' => $this->ideas->get_status_from_id($idea['idea_status']),
201+
'IDEA_STATUS_NAME' => $this->idea->get_status_from_id($idea['idea_status']),
202202

203-
'IDEA_DUPLICATE' => $idea['duplicate_id'] ? $this->ideas->get_title($idea['duplicate_id']) : '',
203+
'IDEA_DUPLICATE' => $idea['duplicate_id'] ? $this->idea->get_title($idea['duplicate_id']) : '',
204204
'IDEA_RFC' => $idea['rfc_link'],
205205
'IDEA_TICKET' => $idea['ticket_id'],
206206
'IDEA_IMPLEMENTED' => $idea['implemented_version'],
@@ -341,7 +341,7 @@ public function submit_idea_after($event)
341341
return;
342342
}
343343

344-
$this->ideas->submit($event['data']);
344+
$this->idea->submit($event['data']);
345345

346346
// Show users who's posts need approval a special message
347347
if (!$this->auth->acl_get('f_noapprove', $event['data']['forum_id']))
@@ -370,8 +370,8 @@ public function edit_idea_title($event)
370370
return;
371371
}
372372

373-
$idea = $this->ideas->get_idea_by_topic_id($event['topic_id']);
374-
$this->ideas->set_title($idea['idea_id'], $event['post_data']['post_subject']);
373+
$idea = $this->idea->get_idea_by_topic_id($event['topic_id']);
374+
$this->idea->set_title($idea['idea_id'], $event['post_data']['post_subject']);
375375
}
376376

377377
/**

0 commit comments

Comments
 (0)