Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 11 additions & 7 deletions libraries/src/Plugin/CMSPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public function __construct($config = [])
}

// Load the language files if needed.
// It is required Application to be set, so we trying it here and in CMSPlugin::setApplication()
if ($this->autoloadLanguage && $this->getApplication()) {
if ($this->autoloadLanguage) {
$this->autoloadLanguage();
}
}
Expand Down Expand Up @@ -253,6 +252,16 @@ final protected function autoloadLanguage(): void

$app = $this->getApplication();

// Try to get Application from Factory
if (!$app) {
try {
$app = Factory::getApplication();
} catch (\Exception) {
// Cannot help here
return;
}
}

// Check whether language already initialised in the Application, otherwise wait for it
if (!$app->getLanguage()) {
$app->getDispatcher()->addListener('onAfterInitialise', function () {
Expand Down Expand Up @@ -483,11 +492,6 @@ public function setApplication(CMSApplicationInterface $application): void
if ($application->getLanguage()) {
$this->setLanguage($application->getLanguage());
}

// Try to load the language files if it were not loaded in the constructor already.
if ($this->autoloadLanguage) {
$this->autoloadLanguage();
}
}

/**
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13676,6 +13676,16 @@ parameters:
count: 1
path: libraries/src/Plugin/CMSPlugin.php

-
message: '''
#^Call to method getDispatcher\(\) of deprecated interface Joomla\\CMS\\Application\\EventAwareInterface\:
4\.3 will be removed in 7\.0
This interface will be removed without replacement as the Joomla 3\.x compatibility layer will be removed$#
'''
identifier: method.deprecatedInterface
count: 1
path: libraries/src/Plugin/CMSPlugin.php

-
message: '''
#^Call to deprecated method getCache\(\) of class Joomla\\CMS\\Factory\:
Expand Down
Loading