- md5
- 986e05cc326f9f6bfac4e92cba49eb7c
- sha1
- 0e9b3c80a4a5fa4b71e863812d5c3e16cd5ac8d0
- sha256
- 1f95c240f27e8dcfa45c4eba45f9471ad6e499f13d774814661446b039ab21e0
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
<?php
/**
* @package Joomla.Plugin
* @subpackage Behaviour.compat
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Behaviour\Compat\Extension;
use Joomla\CMS\Event\Application\AfterInitialiseDocumentEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\Priority;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Joomla! Compat Plugin.
*
* @since 4.4.0
*/
final class Compat extends CMSPlugin implements SubscriberInterface
{
/**
* Returns an array of CMS events this plugin will listen to and the respective handlers.
*
* @return array
*
* @since 4.4.0
*/
public static function getSubscribedEvents(): array
{
/**
* Note that onAfterInitialise must be the first handlers to run for this
* plugin to operate as expected. These handlers load compatibility code which
* might be needed by other plugins
*/
return [
'onAfterInitialiseDocument' => ['onAfterInitialiseDocument', Priority::HIGH],
];
}
/**
* Constructor
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'group', 'params', 'language'
* (this list is not meant to be comprehensive).
*
* @since 1.5
*/
public function __construct(array $config = [])
{
parent::__construct($config);
/**
* Normally we should never use the constructor to execute any logic which would
* affect other parts of the cms, but since we need to load class aliases as
* early as possible we load the class aliases in the constructor so behaviour and system plugins
* which depend on the JPlugin alias for example still are working
*/
/**
* Load class names which are deprecated in joomla 4.0 and which will
* likely be removed in Joomla 6.0
*/
if ($this->params->get('classes_aliases', '1')) {
require_once \dirname(__DIR__) . '/classmap/classmap.php';
}
}
/**
* We run as early as possible, this should be the first event
*
* @param AfterInitialiseDocumentEvent $event
* @return void
*
* @since 5.0.0
*/
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
{
/**
* Load the es5 assets stubs, they are needed if an extension
* directly uses a core es5 asset which has no function in Joomla 5+
* and only provides an empty asset to not throw an exception
*/
if ($this->params->get('es5_assets', '1')) {
$event->getDocument()
->getWebAssetManager()
->getRegistry()
->addRegistryFile('media/plg_behaviour_compat/es5.asset.json');
}
/**
* Load the removed assets stubs, they are needed if an extension
* directly uses a core asset from Joomla 4 which is not present in Joomla 5+
* and only provides an empty asset to not throw an exception
*/
if ($this->params->get('removed_asset', '1')) {
$event->getDocument()
->getWebAssetManager()
->getRegistry()
->addRegistryFile('media/plg_behaviour_compat/removed.asset.json');
}
}
}
The same content is in 25 releases, Joomla 5.4.0-beta2 to 5.4.10. See them all, or every version of this file.