|
10 | 10 |
|
11 | 11 | namespace Joomla\Plugin\System\GuidedTours\Extension; |
12 | 12 |
|
| 13 | +use Joomla\CMS\Event\SubscriberRegistrationCheckerInterface; |
13 | 14 | use Joomla\CMS\Language\Text; |
14 | 15 | use Joomla\CMS\Object\CMSObject; |
15 | 16 | use Joomla\CMS\Plugin\CMSPlugin; |
16 | 17 | use Joomla\CMS\Session\Session; |
17 | 18 | use Joomla\Component\Guidedtours\Administrator\Extension\GuidedtoursComponent; |
18 | 19 | use Joomla\Component\Guidedtours\Administrator\Model\TourModel; |
19 | | -use Joomla\Event\DispatcherInterface; |
20 | 20 | use Joomla\Event\Event; |
21 | 21 | use Joomla\Event\SubscriberInterface; |
22 | 22 |
|
|
29 | 29 | * |
30 | 30 | * @since 4.3.0 |
31 | 31 | */ |
32 | | -final class GuidedTours extends CMSPlugin implements SubscriberInterface |
| 32 | +final class GuidedTours extends CMSPlugin implements SubscriberInterface, SubscriberRegistrationCheckerInterface |
33 | 33 | { |
34 | 34 | /** |
35 | 35 | * A mapping for the step types |
@@ -59,43 +59,30 @@ final class GuidedTours extends CMSPlugin implements SubscriberInterface |
59 | 59 | ]; |
60 | 60 |
|
61 | 61 | /** |
62 | | - * An internal flag whether plugin should listen any event. |
63 | | - * |
64 | | - * @var bool |
65 | | - * |
66 | | - * @since 4.3.0 |
67 | | - */ |
68 | | - protected static $enabled = false; |
69 | | - |
70 | | - /** |
71 | | - * Constructor |
| 62 | + * function for getSubscribedEvents : new Joomla 4 feature |
72 | 63 | * |
73 | | - * @param DispatcherInterface $dispatcher The object to observe |
74 | | - * @param array $config An optional associative array of configuration settings. |
75 | | - * @param boolean $enabled An internal flag whether plugin should listen any event. |
| 64 | + * @return array |
76 | 65 | * |
77 | 66 | * @since 4.3.0 |
78 | 67 | */ |
79 | | - public function __construct(DispatcherInterface $dispatcher, array $config = [], bool $enabled = false) |
| 68 | + public static function getSubscribedEvents(): array |
80 | 69 | { |
81 | | - self::$enabled = $enabled; |
82 | | - |
83 | | - parent::__construct($dispatcher, $config); |
| 70 | + return [ |
| 71 | + 'onAjaxGuidedtours' => 'startTour', |
| 72 | + 'onBeforeCompileHead' => 'onBeforeCompileHead', |
| 73 | + ]; |
84 | 74 | } |
85 | 75 |
|
86 | 76 | /** |
87 | | - * function for getSubscribedEvents : new Joomla 4 feature |
| 77 | + * Check whether the Subscriber should be registered. |
88 | 78 | * |
89 | | - * @return array |
| 79 | + * @return bool |
90 | 80 | * |
91 | | - * @since 4.3.0 |
| 81 | + * @since __DEPLOY_VERSION__ |
92 | 82 | */ |
93 | | - public static function getSubscribedEvents(): array |
| 83 | + public function shouldRegisterListeners(): bool |
94 | 84 | { |
95 | | - return self::$enabled ? [ |
96 | | - 'onAjaxGuidedtours' => 'startTour', |
97 | | - 'onBeforeCompileHead' => 'onBeforeCompileHead', |
98 | | - ] : []; |
| 85 | + return $this->getApplication()->isClient('administrator'); |
99 | 86 | } |
100 | 87 |
|
101 | 88 | /** |
|
0 commit comments