1010
1111namespace Joomla \Plugin \System \Accessibility \Extension ;
1212
13+ use Joomla \CMS \Event \Application \BeforeCompileHeadEvent ;
1314use Joomla \CMS \Plugin \CMSPlugin ;
15+ use Joomla \Event \SubscriberInterface ;
1416
1517// phpcs:disable PSR1.Files.SideEffects
1618\defined ('_JEXEC ' ) or die;
2123 *
2224 * @since 4.0.0
2325 */
24- final class Accessibility extends CMSPlugin
26+ final class Accessibility extends CMSPlugin implements SubscriberInterface
2527{
28+ /**
29+ * Returns an array of events this subscriber will listen to.
30+ *
31+ * @return array
32+ *
33+ * @since __DEPLOY_VERSION__
34+ */
35+ public static function getSubscribedEvents (): array
36+ {
37+ return [
38+ 'onBeforeCompileHead ' => 'onBeforeCompileHead ' ,
39+ ];
40+ }
41+
2642 /**
2743 * Add the javascript for the accessibility menu
2844 *
45+ * @param BeforeCompileHeadEvent $event The event object
46+ *
2947 * @return void
3048 *
3149 * @since 4.0.0
3250 */
33- public function onBeforeCompileHead ()
51+ public function onBeforeCompileHead (BeforeCompileHeadEvent $ event ): void
3452 {
3553 $ section = $ this ->params ->get ('section ' , 'administrator ' );
54+ $ app = $ event ->getApplication ();
3655
37- if ($ section !== 'both ' && $ this -> getApplication () ->isClient ($ section ) !== true ) {
56+ if ($ section !== 'both ' && $ app ->isClient ($ section ) !== true ) {
3857 return ;
3958 }
4059
4160 // Get the document object.
42- $ document = $ this -> getApplication () ->getDocument ();
61+ $ document = $ event ->getDocument ();
4362
4463 if ($ document ->getType () !== 'html ' ) {
4564 return ;
4665 }
4766
4867 // Are we in a modal?
49- if ($ this -> getApplication () ->getInput ()->get ('tmpl ' , '' , 'cmd ' ) === 'component ' ) {
68+ if ($ app ->getInput ()->get ('tmpl ' , '' , 'cmd ' ) === 'component ' ) {
5069 return ;
5170 }
5271
5372 // Load language file.
5473 $ this ->loadLanguage ();
5574
5675 // Determine if it is an LTR or RTL language
57- $ direction = $ this -> getApplication () ->getLanguage ()->isRtl () ? 'right ' : 'left ' ;
76+ $ direction = $ app ->getLanguage ()->isRtl () ? 'right ' : 'left ' ;
5877
5978 // Detect the current active language
60- $ lang = $ this -> getApplication () ->getLanguage ()->getTag ();
79+ $ lang = $ app ->getLanguage ()->getTag ();
6180
6281 /**
6382 * Add strings for translations in Javascript.
@@ -67,20 +86,20 @@ public function onBeforeCompileHead()
6786 'accessibility-options ' ,
6887 [
6988 'labels ' => [
70- 'menuTitle ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_MENU_TITLE ' ),
71- 'increaseText ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_INCREASE_TEXT ' ),
72- 'decreaseText ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_DECREASE_TEXT ' ),
73- 'increaseTextSpacing ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_INCREASE_SPACING ' ),
74- 'decreaseTextSpacing ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_DECREASE_SPACING ' ),
75- 'invertColors ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_INVERT_COLORS ' ),
76- 'grayHues ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_GREY ' ),
77- 'underlineLinks ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_UNDERLINE ' ),
78- 'bigCursor ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_CURSOR ' ),
79- 'readingGuide ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_READING ' ),
80- 'textToSpeech ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_TTS ' ),
81- 'speechToText ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_STT ' ),
82- 'resetTitle ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_RESET ' ),
83- 'closeTitle ' => $ this -> getApplication () ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_CLOSE ' ),
89+ 'menuTitle ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_MENU_TITLE ' ),
90+ 'increaseText ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_INCREASE_TEXT ' ),
91+ 'decreaseText ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_DECREASE_TEXT ' ),
92+ 'increaseTextSpacing ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_INCREASE_SPACING ' ),
93+ 'decreaseTextSpacing ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_DECREASE_SPACING ' ),
94+ 'invertColors ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_INVERT_COLORS ' ),
95+ 'grayHues ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_GREY ' ),
96+ 'underlineLinks ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_UNDERLINE ' ),
97+ 'bigCursor ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_CURSOR ' ),
98+ 'readingGuide ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_READING ' ),
99+ 'textToSpeech ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_TTS ' ),
100+ 'speechToText ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_STT ' ),
101+ 'resetTitle ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_RESET ' ),
102+ 'closeTitle ' => $ app ->getLanguage ()->_ ('PLG_SYSTEM_ACCESSIBILITY_CLOSE ' ),
84103 ],
85104 'icon ' => [
86105 'position ' => [
0 commit comments