Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2][Events] Use event classes for System plugins #43637

Open
wants to merge 19 commits into
base: 5.2-dev
Choose a base branch
from
Prev Previous commit
Next Next commit
system Jooa11y
  • Loading branch information
Fedik committed Jun 8, 2024
commit 3506275a3bd65b8d634ecc0ce9690c155e62b683
12 changes: 6 additions & 6 deletions plugins/system/highlight/src/Extension/Highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Joomla\Plugin\System\Highlight\Extension;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Event\Application\BeforeCompileHeadEvent;
use Joomla\CMS\Event\Application\AfterDispatchEvent;
use Joomla\CMS\Event\Finder\ResultEvent;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Plugin\CMSPlugin;
Expand Down Expand Up @@ -50,21 +50,21 @@ public static function getSubscribedEvents(): array
* The highlighting is done with JavaScript so we just
* need to check a few parameters and the JHtml behavior will do the rest.
*
* @param BeforeCompileHeadEvent $event The event object
* @param AfterDispatchEvent $event The event object
*
* @return void
*
* @since 2.5
*/
public function onAfterDispatch(BeforeCompileHeadEvent $event): void
public function onAfterDispatch(AfterDispatchEvent $event): void
{
// Check that we are in the site application.
if (!$event->getApplication()->isClient('site')) {
return;
}

// Set the variables.
$input = $event->getApplication();
$input = $event->getApplication()->getInput();
$extension = $input->get('option', '', 'cmd');

// Check if the highlighter is enabled.
Expand All @@ -73,7 +73,7 @@ public function onAfterDispatch(BeforeCompileHeadEvent $event): void
}

// Check if the highlighter should be activated in this environment.
if ($input->get('tmpl', '', 'cmd') === 'component' || $this->getApplication()->getDocument()->getType() !== 'html') {
if ($input->get('tmpl', '', 'cmd') === 'component' || $event->getApplication()->getDocument()->getType() !== 'html') {
return;
}

Expand All @@ -96,7 +96,7 @@ public function onAfterDispatch(BeforeCompileHeadEvent $event): void
}

/** @var \Joomla\CMS\Document\HtmlDocument $doc */
$doc = $event->getDocument();
$doc = $event->getApplication()->getDocument();

// Activate the highlighter.
if (!empty($cleanTerms)) {
Expand Down
14 changes: 9 additions & 5 deletions plugins/system/jooa11y/src/Extension/Jooa11y.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Plugin\System\Jooa11y\Extension;

use Joomla\CMS\Event\Application\BeforeCompileHeadEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\SubscriberInterface;

Expand Down Expand Up @@ -74,18 +75,20 @@ private function isAuthorisedDisplayChecker(): bool
/**
* Add the checker.
*
* @param BeforeCompileHeadEvent $event The event object
*
* @return void
*
* @since 4.1.0
*/
public function initJooa11y()
public function initJooa11y(BeforeCompileHeadEvent $event)
{
if (!$this->getApplication()->isClient('site')) {
if (!$event->getApplication()->isClient('site')) {
return;
}

// Check if we are in a preview modal or the plugin has enforced loading
$showJooa11y = $this->getApplication()
$showJooa11y = $event->getApplication()
->getInput()
->get('jooa11y', $this->params->get('showAlways', 0));

Expand All @@ -98,7 +101,7 @@ public function initJooa11y()
$this->loadLanguage();

// Detect the current active language
$getLang = $this->getApplication()
$getLang = $event->getApplication()
->getLanguage()
->getTag();

Expand Down Expand Up @@ -152,7 +155,8 @@ public function initJooa11y()
}

// Get the document object
$document = $this->getApplication()->getDocument();
/** @var \Joomla\CMS\Document\HtmlDocument $document */
$document = $event->getDocument();

// Get plugin options from xml
$getOptions = [
Expand Down