IsReferenceConsideredForDependencyEvent
New in version 14.2 Feature: #108992 - New PSR-14 event for workspace dependency resolution
The PSR-14 event
\TYPO3\
is dispatched per
sys_ row when the workspace dependency
resolver evaluates which references constitute structural dependencies
during publish, stage change, discard, or display operations.
References are opt-in: a reference is not considered a dependency unless a
listener explicitly marks it as one via
set. TYPO3 Core
registers a listener that marks type=inline, type=file (with
foreign_), and type=flex fields as dependencies; this
event allows extensions to opt in additional custom fields, for example
those storing a parent-child relationship outside of TCA's built-in
relation types.
Example: Treat a custom parent-reference field as a dependency
The following listener marks a custom tx_ field on
the
tt_ table as a workspace dependency, so that publishing,
staging, or discarding a child record also considers its parent:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Workspaces\Event\IsReferenceConsideredForDependencyEvent;
#[AsEventListener(identifier: 'my-extension/mark-container-parent-as-workspace-dependency')]
final readonly class MarkContainerParentAsWorkspaceDependencyListener
{
public function __invoke(IsReferenceConsideredForDependencyEvent $event): void
{
if ($event->getTableName() !== 'tt_content' || $event->getFieldName() !== 'tx_container_parent') {
return;
}
$event->setDependency(true);
}
}
API
-
final class
IsReferenceConsideredForDependencyEvent -
- Fully qualified name
-
\TYPO3\CMS\ Workspaces\ Event\ Is Reference Considered For Dependency Event
Event dispatched per sys_refindex row when evaluating workspace dependencies. Listeners decide whether a given reference constitutes a structural workspace dependency.
References are opt-in: isDependency defaults to false and listeners must explicitly mark relevant references as dependencies.
getFlexPointer()-
Path of the FlexForm field the reference originates from (sys_refindex.flexpointer), empty if the reference does not originate from a FlexForm.
- Returns
-
string
getSoftReferenceKey()-
Key of the soft reference parser that found the reference (sys_refindex.softref_key), empty if the reference is no soft reference.
- Returns
-
string
getSoftReferenceId()-
Identifier of the soft reference in the field value (sys_refindex.softref_id), empty if the reference is no soft reference.
- Returns
-
string