Feature: New InlineRelationResolver
Description
EXT: provides the new public service
Inline to
resolve the record owning an inline (IRRE) child record in connected mode, meaning
the parent TCA field uses foreign_ to point back from the child to its
parent.
This information is required to decide whether a record may be localized on its own, or whether the localization has to be triggered through its parent record.
Example
use WebVision\Deepltranslate\Core\Service\InlineRelationResolver;
final readonly class MyService
{
public function __construct(
private InlineRelationResolver $inlineRelationResolver,
) {}
public function isInlineChild(string $table, int $uid): bool
{
return $this->inlineRelationResolver
->resolveParentReference($table, $uid)
->isResolved();
}
}
resolve always returns an
Inline,
never
null
. It carries the outcome as an
Inline and, for
a resolved relation, the
Inline with
the child table and uid, the resolved parent table, parent field and parent uid,
and the name of the foreign_ pointer column.
The state lets a caller tell an ordinary standalone record apart from a broken relation configuration, which matters because only the latter is worth reporting to an editor:
| State | Meaning |
|---|---|
Resolved | Inline child in connected mode, parent resolved unambiguously.
is returns
true
and a reference is carried. |
Not | Not an inline child in connected mode - the common case for any standalone record. Localize normally, do not report. |
Ambiguous | The record could be an inline child of more than one parent at the
same time, for example when multiple parent tables point to the same
child table without using foreign_. Report it. |
Parent | The foreign_ points at a parent record which does not exist
(any more). Report it. |
Parent | Inline child in connected mode, but the parent table is not
translatable, most prominently sys_ owned by
sys_. There can never be a parent localization to attach to, so
the child is localized on its own. Do not report. |
Resolving the parent requires the foreign_ pointer column of the child
record to be written already, which is not the case during most of the
DataHandler processing of newly created child records. For those cases the
service additionally answers the record independent question whether a table can
be used as inline child at all:
$this->inlineRelationResolver->isPossibleInlineChildTable('sys_file_reference');
// true - for example `tt_content.image` owns records of that table
Only parents which can carry a localization themselves are counted here. A table
owned exclusively by untranslatable parents - sys_, owned by
sys_ - is not reported as a possible inline child, because handing its
localization to that parent could never produce anything. This matches the
Parent state of the per-record resolution; both share one
predicate so they cannot drift apart.
Impact
Add-ons dispatching DeepL translations for arbitrary records can detect inline child records without implementing their own TCA analysis.