Skip to content

Commit 8f6a981

Browse files
FediklaoneoHLeithnerrichard67
authored
[5.4] CMSPlugin: deprecation for registerListeners (#43395)
Co-authored-by: Allon Moritz <[email protected]> Co-authored-by: Harald Leithner <[email protected]> Co-authored-by: Richard Fath <[email protected]>
1 parent f2b1243 commit 8f6a981

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

libraries/src/Extension/PluginInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ interface PluginInterface extends DispatcherAwareInterface
3030
* @return void
3131
*
3232
* @since 4.0.0
33+
*
34+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
35+
* Plugin should implement SubscriberInterface.
36+
* These plugins will be added to dispatcher in PluginHelper::import().
3337
*/
3438
public function registerListeners();
3539
}

libraries/src/Plugin/CMSPlugin.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ public function loadLanguage($extension = '', $basePath = JPATH_ADMINISTRATOR)
222222
* @return void
223223
*
224224
* @since 4.0.0
225+
*
226+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
227+
* Plugin should implement SubscriberInterface.
228+
* These plugins will be added to dispatcher in PluginHelper::import().
225229
*/
226230
public function registerListeners()
227231
{
@@ -232,6 +236,8 @@ public function registerListeners()
232236
return;
233237
}
234238

239+
@trigger_error('The plugin should implement SubscriberInterface.', \E_USER_DEPRECATED);
240+
235241
$reflectedObject = new \ReflectionObject($this);
236242
$methods = $reflectedObject->getMethods(\ReflectionMethod::IS_PUBLIC);
237243

@@ -287,6 +293,9 @@ public function registerListeners()
287293
* @return void
288294
*
289295
* @since 4.0.0
296+
*
297+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
298+
* Plugin should implement SubscriberInterface.
290299
*/
291300
final protected function registerLegacyListener(string $methodName)
292301
{
@@ -335,6 +344,9 @@ function (AbstractEvent $event) use ($methodName) {
335344
* @return void
336345
*
337346
* @since 4.0.0
347+
*
348+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
349+
* Plugin should implement SubscriberInterface.
338350
*/
339351
final protected function registerListener(string $methodName)
340352
{
@@ -349,6 +361,9 @@ final protected function registerListener(string $methodName)
349361
* @return boolean
350362
*
351363
* @since 4.0.0
364+
*
365+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
366+
* Plugin should implement SubscriberInterface.
352367
*/
353368
private function parameterImplementsEventInterface(\ReflectionParameter $parameter): bool
354369
{

libraries/src/Plugin/PluginHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa
239239
return;
240240
}
241241

242+
// @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin); for plugins which implement SubscriberInterface.
242243
$plugin->registerListeners();
243244
}
244245

0 commit comments

Comments
 (0)