Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
12b3977
CMSPlugin: use Lazy Object feature
Fedik Mar 3, 2025
01e632f
CMSPlugin: use Lazy Object feature
Fedik Mar 3, 2025
a6fb246
Update libraries/src/Plugin/CMSPlugin.php
Fedik Mar 3, 2025
4142bc7
CMSPlugin: use Lazy Object feature
Fedik Mar 3, 2025
6546c55
CMSPlugin: use Lazy Object feature
Fedik Mar 3, 2025
23778ea
tst
Fedik Mar 3, 2025
c7fa33a
tst
Fedik Mar 3, 2025
d27ee97
Use lazy proxy
Fedik Mar 3, 2025
48a3950
Merge branch '6.0-dev' into plugin-lazy-objects
HLeithner Mar 6, 2025
36fe142
tst
Fedik Mar 9, 2025
b76f77f
tst
Fedik Mar 9, 2025
bf94b46
Merge branch '6.0-dev' into plugin-lazy-objects
Fedik Mar 12, 2025
50a7386
LazySubscriberInterface
Fedik Mar 12, 2025
def84d0
simplify
Fedik Mar 12, 2025
02486fb
fix
Fedik Mar 12, 2025
c16cc08
fix
Fedik Mar 12, 2025
1ebfa85
fix
Fedik Mar 12, 2025
56ff36f
fix
Fedik Mar 12, 2025
b1edeba
fix
Fedik Mar 12, 2025
eaad966
fix
Fedik Mar 12, 2025
d768e43
implement once
Fedik Mar 13, 2025
fb10ee0
PluginWithSubscriberInterface
Fedik Mar 13, 2025
8b60479
fix
Fedik Mar 13, 2025
3bcafcc
fix
Fedik Mar 13, 2025
4aa834f
re arrange
Fedik Mar 13, 2025
e49a486
Merge branch '6.0-dev' into plugin-lazy-objects
Fedik May 3, 2025
d6049dc
Merge branch '6.0-dev' into plugin-lazy-objects
Fedik Jun 7, 2025
acf47fc
set Dispatcher in the plugin service provider
Fedik Jun 7, 2025
6974249
use reflection
Fedik Jun 7, 2025
97c0b79
fixes
Fedik Jun 7, 2025
f5fe026
Merge branch '6.0-dev' into plugin-lazy-objects
Fedik Aug 12, 2025
b1314d1
use di helper
Fedik Aug 12, 2025
83f961e
phpstan
Fedik Aug 12, 2025
608b6b9
Merge branch '6.0-dev' into plugin-lazy-objects
muhme Aug 21, 2025
230bc18
Merge branch '6.0-dev' into plugin-lazy-objects
Fedik Aug 28, 2025
d7f1a31
typo
Fedik Aug 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions libraries/src/Plugin/PluginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Factory;
use Joomla\Event\DispatcherAwareInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -231,16 +232,26 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa

$plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type);

if ($dispatcher && $plugin instanceof DispatcherAwareInterface) {
$plugin->setDispatcher($dispatcher);
}

if (!$autocreate) {
return;
}

// @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin); for plugins which implement SubscriberInterface.
$plugin->registerListeners();
// Check for overridden registerListeners()
$reflection = new \ReflectionClass($plugin);
$registerOverridden = $reflection->hasMethod('registerListeners') && $reflection->getMethod('registerListeners')->class !== CMSPlugin::class;

// @TODO: From 7.0 when registerListeners() will be removed from CMSPlugin checking for overridden registerListeners() need to be removed.
if ($plugin instanceof SubscriberInterface && !$registerOverridden) {
$dispatcher->addSubscriber($plugin);
} else {
// @TODO: From 7.0 when DispatcherAwareInterface will be removed from CMSPlugin this should be checked for all plugins.
if ($dispatcher && $plugin instanceof DispatcherAwareInterface) {
$plugin->setDispatcher($dispatcher);
}

// @TODO: From 7.0 it should use $dispatcher->addSubscriber($plugin); for plugins which implement SubscriberInterface.
$plugin->registerListeners();
}
}

/**
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15221,6 +15221,16 @@ parameters:
count: 4
path: plugins/system/cache/src/Extension/Cache.php

-
message: '''
#^Call to deprecated method setDispatcher\(\) of class Joomla\\Plugin\\System\\Cache\\Extension\\Cache\:
5\.2 will be removed in 7\.0
Plugin should implement DispatcherAwareInterface on its own, when it is needed\.$#
'''
identifier: method.deprecated
count: 1
path: plugins/system/cache/src/Extension/Cache.php

-
message: '''
#^Call to deprecated method getLanguage\(\) of class Joomla\\CMS\\Factory\:
Expand Down
6 changes: 3 additions & 3 deletions plugins/system/schedulerunner/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public function register(Container $container): void
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new ScheduleRunner(
$container->lazy(ScheduleRunner::class, function (Container $container) {
$plugin = new ScheduleRunner(
(array) PluginHelper::getPlugin('system', 'schedulerunner')
);
$plugin->setApplication(Factory::getApplication());

return $plugin;
}
})
);
}
};
6 changes: 3 additions & 3 deletions plugins/system/tasknotification/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public function register(Container $container): void
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new TaskNotification(
$container->lazy(TaskNotification::class, function (Container $container) {
$plugin = new TaskNotification(
(array) PluginHelper::getPlugin('system', 'tasknotification')
);
$plugin->setApplication(Factory::getApplication());
$plugin->setDatabase($container->get(DatabaseInterface::class));
$plugin->setUserFactory($container->get(UserFactoryInterface::class));

return $plugin;
}
})
);
}
};
8 changes: 4 additions & 4 deletions plugins/system/webauthn/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$container->lazy(Webauthn::class, function (Container $container) {
$app = Factory::getApplication();
$session = $container->has('session') ? $container->get('session') : $this->getSession($app);

Expand All @@ -53,12 +53,12 @@ function (Container $container) {
$params = new Registry($config['params'] ?? '{}');

if ($params->get('attestationSupport', 0) == 1) {
$metadataRepository = $container->has(MetadataStatementRepository::class)
$metadataRepository = $container->has(MetadataStatementRepository::class)
? $container->get(MetadataStatementRepository::class)
: new MetadataRepository();
}

$authenticationHelper = $container->has(Authentication::class)
$authenticationHelper = $container->has(Authentication::class)
? $container->get(Authentication::class)
: new Authentication($app, $session, $credentialsRepository, $metadataRepository);

Expand All @@ -69,7 +69,7 @@ function (Container $container) {
$plugin->setApplication($app);

return $plugin;
}
})
);
}

Expand Down
Loading