Skip to content

Commit 8d1d99a

Browse files
authored
[5.4] Deprecate app property in FieldsPlugin (joomla#45695)
* [5.4] Deprecate app property in FieldsPlugin (Custom Fields)
1 parent 30c09e5 commit 8d1d99a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

administrator/components/com_fields/src/Plugin/FieldsPlugin.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ abstract class FieldsPlugin extends CMSPlugin
4545
*
4646
* @var \Joomla\CMS\Application\CMSApplication
4747
* @since 4.0.0
48+
*
49+
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0 use $this->getApplication() instead
4850
*/
4951
protected $app;
5052

@@ -138,6 +140,7 @@ public function onCustomFieldsGetTypes()
138140
return $types_cache[$this->_type . $this->_name];
139141
}
140142

143+
$app = $this->getApplication() ?: $this->app;
141144
$types = [];
142145

143146
// The root of the plugin
@@ -160,11 +163,11 @@ public function onCustomFieldsGetTypes()
160163
// Needed attributes
161164
$data['type'] = $layout;
162165

163-
if ($this->app->getLanguage()->hasKey('PLG_FIELDS_' . $key . '_LABEL')) {
166+
if ($app->getLanguage()->hasKey('PLG_FIELDS_' . $key . '_LABEL')) {
164167
$data['label'] = Text::sprintf('PLG_FIELDS_' . $key . '_LABEL', strtolower($key));
165168

166169
// Fix wrongly set parentheses in RTL languages
167-
if ($this->app->getLanguage()->isRtl()) {
170+
if ($app->getLanguage()->isRtl()) {
168171
$data['label'] .= '‎';
169172
}
170173
} else {

phpstan-baseline.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,15 @@ parameters:
21182118
count: 1
21192119
path: administrator/components/com_fields/src/Model/GroupModel.php
21202120

2121+
-
2122+
message: '''
2123+
#^Access to deprecated property \$app of class Joomla\\Component\\Fields\\Administrator\\Plugin\\FieldsPlugin\:
2124+
__DEPLOY_VERSION__ will be removed in 7\.0 use \$this\-\>getApplication\(\) instead$#
2125+
'''
2126+
identifier: property.deprecated
2127+
count: 1
2128+
path: administrator/components/com_fields/src/Plugin/FieldsPlugin.php
2129+
21212130
-
21222131
message: '''
21232132
#^Call to deprecated method getUser\(\) of class Joomla\\CMS\\Factory\:

0 commit comments

Comments
 (0)