Skip to content

Commit ef18543

Browse files
committed
feat : add ogtest field plugin
1 parent 30689d6 commit ef18543

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,5 @@ cypress.config.mjs
107107

108108
# WebAuthn FIDO metadata cache
109109
/plugins/system/webauthn/fido.jwt
110+
111+
/plugins/fields/ogtest

libraries/src/Opengraph/OpengraphServiceInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ interface MappableFieldInterface
8181
*
8282
* @since __DEPLOY_VERSION__
8383
*/
84-
public function getOpengraphGroup(): OpengraphGroup;
84+
public static function getOpengraphGroup(): OpengraphGroup;
8585
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void
265265
['ignore_request' => true]
266266
);
267267
$categoryModel->setState('category.id', $article->catid);
268-
$category = $categoryModel->getItem($article->catid);
268+
$category = $categoryModel->getCategory();
269269

270270

271271

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,29 @@ protected function getGroups()
113113

114114
// If not native-allowed, see if the field’s plugin implements our interface
115115
if (!$accept) {
116-
// Class name convention: PlgFields{Type}
117-
$class = 'PlgFields' . ucfirst($field->type);
118-
119-
// Ensure plugin autoloaded
120-
PluginHelper::importPlugin('fields');
121-
122-
if (
123-
\class_exists($class)
124-
&& \is_subclass_of($class, MappableFieldInterface::class)
125-
&& $class::getOpengraphGroup()->value === $fieldType
126-
) {
127-
$accept = true;
116+
117+
// Ensure the specific fields plugin is loaded
118+
PluginHelper::importPlugin('fields', $field->type);
119+
120+
$ucType = ucfirst((string) $field->type);
121+
122+
// Candidate class names in priority order (modern first, then legacy)
123+
$candidates = [
124+
"Joomla\\Plugin\\Fields\\{$ucType}\\Extension\\{$ucType}", // J4/5 namespaced
125+
"Joomla\\Plugin\\Fields\\{$ucType}\\Field\\{$ucType}Field", // some third-party patterns
126+
"PlgFields{$ucType}", // legacy non-namespaced
127+
];
128+
129+
$implements = false;
130+
131+
foreach ($candidates as $fqcn) {
132+
if (\class_exists($fqcn) && \is_subclass_of($fqcn, MappableFieldInterface::class)) {
133+
$implements = ($fqcn::getOpengraphGroup()->value === $fieldType);
134+
if ($implements) {
135+
$accept = true;
136+
break;
137+
}
138+
}
128139
}
129140
}
130141

0 commit comments

Comments
 (0)