Skip to content

Commit cbbff6c

Browse files
committed
Chore: Apply PHP-CS-Fixer formatting across the codebase
1 parent 19fe1f7 commit cbbff6c

File tree

3 files changed

+68
-72
lines changed

3 files changed

+68
-72
lines changed

administrator/components/com_content/src/Extension/ContentComponent.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,26 +220,26 @@ public function getOpengraphFields(): array
220220

221221
$fields = [
222222
'text-fields' => [
223-
'title' => Text::_('JGLOBAL_TITLE'),
223+
'title' => Text::_('JGLOBAL_TITLE'),
224224
'articletext' => Text::_('COM_CONTENT_FIELD_ARTICLETEXT_LABEL'),
225-
'alias' => Text::_('JFIELD_ALIAS_LABEL'),
226-
'metadesc' => Text::_('JFIELD_META_DESCRIPTION_LABEL'),
225+
'alias' => Text::_('JFIELD_ALIAS_LABEL'),
226+
'metadesc' => Text::_('JFIELD_META_DESCRIPTION_LABEL'),
227227
],
228228

229229
'image-fields' => [
230-
'image_intro' => Text::_('COM_CONTENT_FIELD_INTRO_LABEL'),
230+
'image_intro' => Text::_('COM_CONTENT_FIELD_INTRO_LABEL'),
231231
'image_fulltext' => Text::_('COM_CONTENT_FIELD_FULL_LABEL'),
232232

233233
],
234234

235235
'image-alt-fields' => [
236-
'image_intro_alt' => Text::_('COM_CONTENT_FIELD_INTRO_LABEL') . ' - ' . Text::_('COM_CONTENT_FIELD_IMAGE_ALT_LABEL'),
236+
'image_intro_alt' => Text::_('COM_CONTENT_FIELD_INTRO_LABEL') . ' - ' . Text::_('COM_CONTENT_FIELD_IMAGE_ALT_LABEL'),
237237
'image_fulltext_alt' => Text::_('COM_CONTENT_FIELD_FULL_LABEL') . ' - ' . Text::_('COM_CONTENT_FIELD_IMAGE_ALT_LABEL'),
238238
],
239239

240240
'meta-fields' => [
241241
'metadesc' => Text::_('JFIELD_META_DESCRIPTION_LABEL'),
242-
'metakey' => Text::_('JFIELD_META_KEYWORDS_LABEL'),
242+
'metakey' => Text::_('JFIELD_META_KEYWORDS_LABEL'),
243243
],
244244

245245

@@ -248,15 +248,15 @@ public function getOpengraphFields(): array
248248
],
249249

250250
'author-fields' => [
251-
'created_by' => Text::_('COM_CONTENT_FIELD_CREATED_BY_LABEL'),
251+
'created_by' => Text::_('COM_CONTENT_FIELD_CREATED_BY_LABEL'),
252252
'created_by_alias' => Text::_('COM_CONTENT_FIELD_CREATED_BY_ALIAS_LABEL'),
253-
'modified_by' => Text::_('JGLOBAL_FIELD_MODIFIED_BY_LABEL'),
253+
'modified_by' => Text::_('JGLOBAL_FIELD_MODIFIED_BY_LABEL'),
254254

255255
],
256256
'date-fields' => [
257-
'created' => Text::_('COM_CONTENT_FIELD_CREATED_LABEL'),
258-
'modified' => Text::_('JGLOBAL_FIELD_MODIFIED_LABEL'),
259-
'publish_up' => Text::_('COM_CONTENT_FIELD_PUBLISH_UP_LABEL'),
257+
'created' => Text::_('COM_CONTENT_FIELD_CREATED_LABEL'),
258+
'modified' => Text::_('JGLOBAL_FIELD_MODIFIED_LABEL'),
259+
'publish_up' => Text::_('COM_CONTENT_FIELD_PUBLISH_UP_LABEL'),
260260
'publish_down' => Text::_('COM_CONTENT_FIELD_PUBLISH_DOWN_LABEL'),
261261
],
262262

plugins/system/opengraph/src/Extension/opengraph.php

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@
1111
namespace Joomla\Plugin\System\Opengraph\Extension;
1212

1313
use Joomla\CMS\Application\CMSApplication;
14+
use Joomla\CMS\Component\ComponentHelper;
15+
use Joomla\CMS\Document\Document;
16+
use Joomla\CMS\Document\HtmlDocument;
1417
use Joomla\CMS\Event\Application\BeforeCompileHeadEvent;
1518
use Joomla\CMS\Event\Model\PrepareFormEvent;
16-
use Joomla\CMS\Plugin\CMSPlugin;
17-
use Joomla\Event\SubscriberInterface;
18-
use Joomla\CMS\Document\HtmlDocument;
19-
use Joomla\Registry\Registry;
20-
use Joomla\CMS\Document\Document;
19+
use Joomla\CMS\Menu\MenuItem;
20+
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
2121
use Joomla\CMS\Opengraph\OpengraphServiceInterface;
22+
use Joomla\CMS\Plugin\CMSPlugin;
2223
use Joomla\CMS\Uri\Uri;
23-
use Exception;
24-
use Joomla\CMS\Component\ComponentHelper;
25-
use Joomla\CMS\Menu\MenuItem;
26-
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
2724
use Joomla\Component\Content\Site\Model\ArticleModel;
2825
use Joomla\Component\Content\Site\Model\CategoryModel;
29-
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
30-
31-
26+
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
27+
use Joomla\Event\SubscriberInterface;
28+
use Joomla\Registry\Registry;
3229

3330
// phpcs:disable PSR1.Files.SideEffects
3431
\defined('_JEXEC') or die;
@@ -43,7 +40,6 @@
4340

4441
final class Opengraph extends CMSPlugin implements SubscriberInterface
4542
{
46-
4743
/**
4844
* The application object.
4945
*
@@ -69,7 +65,7 @@ final class Opengraph extends CMSPlugin implements SubscriberInterface
6965
public static function getSubscribedEvents(): array
7066
{
7167
return [
72-
'onBeforeCompileHead' => 'onBeforeCompileHead',
68+
'onBeforeCompileHead' => 'onBeforeCompileHead',
7369
'onContentPrepareForm' => 'onContentPrepareForm',
7470
];
7571
}
@@ -92,7 +88,7 @@ public function onContentPrepareForm(PrepareFormEvent $event): void
9288
}
9389

9490
$isCategory = $context === 'com_categories.categorycom_content';
95-
$isMenu = $context === 'com_menus.item';
91+
$isMenu = $context === 'com_menus.item';
9692

9793
$groupName = $isMenu ? 'params' : 'attribs';
9894

@@ -101,7 +97,7 @@ public function onContentPrepareForm(PrepareFormEvent $event): void
10197
try {
10298
$form::addFormPath(__DIR__ . '/../forms');
10399
$form->loadFile('opengraphmappings', false);
104-
} catch (Exception $e) {
100+
} catch (\Exception $e) {
105101
error_log('OpenGraph Plugin: Failed to load mappings form: ' . $e->getMessage());
106102
}
107103

@@ -114,7 +110,7 @@ public function onContentPrepareForm(PrepareFormEvent $event): void
114110
try {
115111
$modifiedXml = $this->adjustFieldsGroup($mainXml, $groupName);
116112
$form->load($modifiedXml, false);
117-
} catch (Exception $e) {
113+
} catch (\Exception $e) {
118114
error_log('OpenGraph Plugin: Failed to load main form: ' . $e->getMessage());
119115
}
120116
}
@@ -148,7 +144,7 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void
148144
$input = $app->input;
149145
if (
150146
$input->getCmd('option') !== 'com_content'
151-
|| $input->getCmd('view') !== 'article'
147+
|| $input->getCmd('view') !== 'article'
152148
|| ! $id = $input->getInt('id')
153149
) {
154150
return;
@@ -167,7 +163,7 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void
167163
$params = ComponentHelper::getParams('com_content');
168164
// Fallback if for some reason it isn’t an object
169165
if (! $params instanceof Registry) {
170-
$params = new Registry;
166+
$params = new Registry();
171167
}
172168

173169
/** @var ArticleModel $articleModel */
@@ -194,29 +190,29 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void
194190

195191

196192
// Get menu parameters
197-
$menuParams = $this->getMenuParams();
193+
$menuParams = $this->getMenuParams();
198194
$articleAttribs = new Registry($article->attribs ?? '{}');
199195
$categoryParams = new Registry($category->params ?? '{}');
200-
$articleImages = $this->getAllArticleImages(new Registry($article->images ?? '{}'));
196+
$articleImages = $this->getAllArticleImages(new Registry($article->images ?? '{}'));
201197

202198

203199

204200
$ogTags = [
205-
'og_title' => '',
206-
'og_description' => '',
207-
'og_image' => '',
208-
'og_image_alt' => '',
209-
'og_type' => '',
210-
'og_url' => '',
211-
'twitter_card' => '',
212-
'twitter_title' => '',
201+
'og_title' => '',
202+
'og_description' => '',
203+
'og_image' => '',
204+
'og_image_alt' => '',
205+
'og_type' => '',
206+
'og_url' => '',
207+
'twitter_card' => '',
208+
'twitter_title' => '',
213209
'twitter_description' => '',
214-
'twitter_image' => '',
215-
'twitter_image_alt' => '',
216-
'fb_app_id' => '',
217-
'site_name' => '',
218-
'url' => '',
219-
'base_url' => ''
210+
'twitter_image' => '',
211+
'twitter_image_alt' => '',
212+
'fb_app_id' => '',
213+
'site_name' => '',
214+
'url' => '',
215+
'base_url' => '',
220216
];
221217

222218
// Get Global settings
@@ -225,8 +221,8 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void
225221

226222
$ogTags['fb_app_id'] = $this->params->get('fb_app_id');
227223
$ogTags['site_name'] = $config->get('sitename');
228-
$ogTags['base_url'] = Uri::base();
229-
$ogTags['url'] = Uri::getInstance()->toString();
224+
$ogTags['base_url'] = Uri::base();
225+
$ogTags['url'] = Uri::getInstance()->toString();
230226

231227
// get OG tags from category mappings
232228
$this->getOgTagsFromCategoryMappings($categoryParams, $article, $articleImages, $ogTags);
@@ -261,7 +257,7 @@ private function getOgTagsFromCategoryMappings(Registry $categoryParams, object
261257
if (strpos($key, 'og_') === 0 && str_ends_with($key, '_field')) {
262258
$ogTagName = substr($key, 0, -6); // Remove "_field" from the end
263259

264-
$value = $this->getFieldValue($article, $fieldName, $articleImages);
260+
$value = $this->getFieldValue($article, $fieldName, $articleImages);
265261
$ogTags[$ogTagName] = $value;
266262
}
267263
}
@@ -360,7 +356,7 @@ private function getFieldValue(object $article, string $fieldName, array $articl
360356
*/
361357
private function getAllArticleImages(Registry $articleImages): array
362358
{
363-
$image_intro = $image_intro_alt = '';
359+
$image_intro = $image_intro_alt = '';
364360
$image_fulltext = $image_fulltext_alt = '';
365361

366362
// Handle image_intro
@@ -383,9 +379,9 @@ private function getAllArticleImages(Registry $articleImages): array
383379
}
384380

385381
return [
386-
'image_intro' => $image_intro,
387-
'image_intro_alt' => $image_intro_alt,
388-
'image_fulltext' => $image_fulltext,
382+
'image_intro' => $image_intro,
383+
'image_intro_alt' => $image_intro_alt,
384+
'image_fulltext' => $image_fulltext,
389385
'image_fulltext_alt' => $image_fulltext_alt,
390386
];
391387
}
@@ -427,10 +423,10 @@ private function getOgTagsFromParams(Registry $params, array &$ogTags): void
427423
private function getTwitterOgTags(array &$ogTags): void
428424
{
429425
$twitterTags = [
430-
'twitter_title' => $ogTags['twitter_title'],
426+
'twitter_title' => $ogTags['twitter_title'],
431427
'twitter_description' => $ogTags['twitter_description'],
432-
'twitter_image' => $ogTags['twitter_image'],
433-
'twitter_image_alt' => $ogTags['twitter_image_alt']
428+
'twitter_image' => $ogTags['twitter_image'],
429+
'twitter_image_alt' => $ogTags['twitter_image_alt'],
434430
];
435431
foreach ($twitterTags as $key => $value) {
436432
// If the value is not set, use the OG value
@@ -497,10 +493,10 @@ private function setOpenGraphImage(
497493
Document $document,
498494
array $ogTags
499495
): void {
500-
$image = $ogTags['og_image'];
501-
$alt = $ogTags['og_image_alt'];
502-
$baseUrl = $ogTags['base_url'];
503-
$twitterImage = $ogTags['twitter_image'];
496+
$image = $ogTags['og_image'];
497+
$alt = $ogTags['og_image_alt'];
498+
$baseUrl = $ogTags['base_url'];
499+
$twitterImage = $ogTags['twitter_image'];
504500
$twitterImageAlt = $ogTags['twitter_image_alt'];
505501

506502
if (empty($image) || !empty($document->getMetaData('og:image'))) {
@@ -564,7 +560,7 @@ protected function isSupported($context): bool
564560

565561
try {
566562
$component = $this->getApplication()->bootComponent($componentName);
567-
} catch (Exception $e) {
563+
} catch (\Exception $e) {
568564
error_log('OpenGraph Plugin: Failed to boot component: ' . $e->getMessage());
569565
return false;
570566
}
@@ -585,10 +581,10 @@ protected function isSupported($context): bool
585581
private function adjustFieldsGroup(string $filePath, string $newGroup): string
586582
{
587583
$xmlContent = file_get_contents($filePath);
588-
$xml = simplexml_load_string($xmlContent);
584+
$xml = simplexml_load_string($xmlContent);
589585

590586
if ($xml === false) {
591-
throw new Exception("Could not load XML file: {$filePath}");
587+
throw new \Exception("Could not load XML file: {$filePath}");
592588
}
593589

594590
// Adjust all <fields> nodes to use the desired group

plugins/system/opengraph/src/Field/OpengraphField.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
use Joomla\CMS\Fields\FieldsServiceInterface;
1414
use Joomla\CMS\Form\Field\GroupedlistField;
1515
use Joomla\CMS\HTML\HTMLHelper;
16+
use Joomla\CMS\Language\Text;
1617
use Joomla\CMS\Opengraph\OpengraphServiceInterface;
1718
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
18-
use Joomla\CMS\Language\Text;
1919

2020
// phpcs:disable PSR1.Files.SideEffects
2121
\defined('_JEXEC') or die;
@@ -48,11 +48,11 @@ class OpengraphField extends GroupedlistField
4848
*/
4949
protected function getGroups()
5050
{
51-
$app = Factory::getApplication();
51+
$app = Factory::getApplication();
5252
$groups = [];
5353

5454
$groups[''] = [
55-
HTMLHelper::_('select.option', '', Text::_('PLG_SYSTEM_OPENGRAPH_NO_FIELD_SELECTED'))
55+
HTMLHelper::_('select.option', '', Text::_('PLG_SYSTEM_OPENGRAPH_NO_FIELD_SELECTED')),
5656
];
5757

5858

@@ -63,7 +63,7 @@ protected function getGroups()
6363
return $groups;
6464
}
6565

66-
$fields = $component->getOpengraphFields();
66+
$fields = $component->getOpengraphFields();
6767
$fieldType = $this->getAttribute('field-type');
6868

6969
if (isset($fields[$fieldType])) {
@@ -83,8 +83,8 @@ protected function getGroups()
8383

8484
// Allowed field types for each OpenGraph group
8585
$allowedFieldTypes = [
86-
'text-fields' => ['text', 'textarea'],
87-
'image-fields' => ['media', 'imagelist'],
86+
'text-fields' => ['text', 'textarea'],
87+
'image-fields' => ['media', 'imagelist'],
8888
'image-alt-fields' => ['text'],
8989
];
9090

@@ -101,15 +101,15 @@ protected function getGroups()
101101
// Dummy item with catid so FieldsService filters by assignment
102102
$scopeItem = $catId ? (object) ['catid' => $catId] : null;
103103

104-
$customFields = FieldsHelper::getFields('com_content.article', $scopeItem);
104+
$customFields = FieldsHelper::getFields('com_content.article', $scopeItem);
105105
$customOptions = [];
106106

107107
foreach ($customFields as $field) {
108-
if (!in_array($field->type, $allowedTypes, true)) {
108+
if (!\in_array($field->type, $allowedTypes, true)) {
109109
continue;
110110
}
111111

112-
$label = $field->title . ' (' . $field->name . ')';
112+
$label = $field->title . ' (' . $field->name . ')';
113113
$customOptions[] = HTMLHelper::_('select.option', 'field.' . $field->name, $label);
114114
}
115115

0 commit comments

Comments
 (0)