do not allow forbidden link name

This commit is contained in:
Yurii
2026-03-02 20:32:00 +02:00
parent 3a2eb429f1
commit 2cb70969bf
@@ -278,6 +278,9 @@ class LinkManager
throw new Conflict("Field $entityForeign::$linkForeign already exists.");
}
$this->checkLinkNameNotForbidden($link);
$this->checkLinkNameNotForbidden($linkForeign);
if ($entity === $entityForeign) {
if (
$link === lcfirst($entity) ||
@@ -1196,4 +1199,23 @@ class LinkManager
$this->metadata->save();
}
/**
* @throws Conflict
*/
private function checkLinkNameNotForbidden(string $link): void
{
if (
in_array($link, NameUtil::FIELD_FORBIDDEN_NAME_LIST)
) {
throw Conflict::createWithBody(
"Field '$link' is not allowed.",
Error\Body::create()
->withMessageTranslation('fieldNameIsNotAllowed', 'FieldManager', [
'field' => $link,
])
->encode()
);
}
}
}