1919* enable_step(), disable_step() and purge_step(). As it is, these methods are defined
2020* in phpbb_extension_base, which this class extends, but you can overwrite them to
2121* give special instructions for those cases. Board Rules must do this because it uses
22- * the notifications system, which requires the methods enable_notifications(),
22+ * the notifications' system, which requires the methods enable_notifications(),
2323* disable_notifications() and purge_notifications() be run to properly manage the
2424* notifications created by Board Rules when enabling, disabling or deleting this
2525* extension.
2626*/
2727class ext extends \phpbb \extension \base
2828{
2929 /**
30- * Check whether or not the extension can be enabled.
30+ * Check whether the extension can be enabled.
3131 * The current phpBB version should meet or exceed
3232 * the minimum version required by this extension:
3333 *
@@ -46,88 +46,67 @@ public function is_enableable()
4646 * before any included migrations are installed.
4747 *
4848 * @param mixed $old_state State returned by previous call of this method
49- * @return mixed Returns false after last step, otherwise temporary state
49+ * @return bool|string Returns false after last step, otherwise temporary state
5050 * @access public
5151 */
5252 public function enable_step ($ old_state )
5353 {
54- switch ($ old_state )
54+ // if nothing has run yet
55+ if ($ old_state === false )
5556 {
56- case '' : // Empty means nothing has run yet
57-
58- // Enable board rules notifications
59- $ phpbb_notifications = $ this ->container ->get ('notification_manager ' );
60- $ phpbb_notifications ->enable_notifications ('phpbb.boardrules.notification.type.boardrules ' );
61- return 'notifications ' ;
62-
63- break ;
64-
65- default :
66-
67- // Run parent enable step method
68- return parent ::enable_step ($ old_state );
69-
70- break ;
57+ // Enable board rules notifications
58+ $ phpbb_notifications = $ this ->container ->get ('notification_manager ' );
59+ $ phpbb_notifications ->enable_notifications ('phpbb.boardrules.notification.type.boardrules ' );
60+ return 'notifications ' ;
7161 }
62+
63+ // Run parent enable step method
64+ return parent ::enable_step ($ old_state );
7265 }
7366
7467 /**
7568 * Overwrite disable_step to disable board rules notifications
7669 * before the extension is disabled.
7770 *
7871 * @param mixed $old_state State returned by previous call of this method
79- * @return mixed Returns false after last step, otherwise temporary state
72+ * @return bool|string Returns false after last step, otherwise temporary state
8073 * @access public
8174 */
8275 public function disable_step ($ old_state )
8376 {
84- switch ($ old_state )
77+ // if nothing has run yet
78+ if ($ old_state === false )
8579 {
86- case '' : // Empty means nothing has run yet
87-
88- // Disable board rules notifications
89- $ phpbb_notifications = $ this ->container ->get ('notification_manager ' );
90- $ phpbb_notifications ->disable_notifications ('phpbb.boardrules.notification.type.boardrules ' );
91- return 'notifications ' ;
92-
93- break ;
94-
95- default :
96-
97- // Run parent disable step method
98- return parent ::disable_step ($ old_state );
99-
100- break ;
80+ // Disable board rules notifications
81+ $ phpbb_notifications = $ this ->container ->get ('notification_manager ' );
82+ $ phpbb_notifications ->disable_notifications ('phpbb.boardrules.notification.type.boardrules ' );
83+ return 'notifications ' ;
10184 }
85+
86+ // Run parent disable step method
87+ return parent ::disable_step ($ old_state );
10288 }
10389
10490 /**
10591 * Overwrite purge_step to purge board rules notifications before
10692 * any included and installed migrations are reverted.
10793 *
10894 * @param mixed $old_state State returned by previous call of this method
109- * @return mixed Returns false after last step, otherwise temporary state
95+ * @return bool|string Returns false after last step, otherwise temporary state
11096 * @access public
11197 */
11298 public function purge_step ($ old_state )
11399 {
114- switch ($ old_state )
100+ // if nothing has run yet
101+ if ($ old_state === false )
115102 {
116- case '' : // Empty means nothing has run yet
117-
118- // Purge board rules notifications
119- $ phpbb_notifications = $ this ->container ->get ('notification_manager ' );
120- $ phpbb_notifications ->purge_notifications ('phpbb.boardrules.notification.type.boardrules ' );
121- return 'notifications ' ;
122-
123- break ;
124-
125- default :
126-
127- // Run parent purge step method
128- return parent ::purge_step ($ old_state );
129-
130- break ;
103+ // Purge board rules notifications
104+ $ phpbb_notifications = $ this ->container ->get ('notification_manager ' );
105+ $ phpbb_notifications ->purge_notifications ('phpbb.boardrules.notification.type.boardrules ' );
106+ return 'notifications ' ;
131107 }
108+
109+ // Run parent purge step method
110+ return parent ::purge_step ($ old_state );
132111 }
133112}
0 commit comments