Feature: #108992 - New PSR-14 event for workspace dependency resolution
See forge#108992
Description
A new PSR-14 event
\TYPO3\
has been added. It is dispatched for each
sys_ row when the
workspace dependency resolver evaluates which references constitute structural
dependencies during publish, stage, discard, and display operations.
Listeners decide whether a particular reference should be treated as a workspace dependency. References are opt-in: the default is "not a dependency", and listeners must explicitly mark relevant references.
The event has the following methods:
get: The table owning the field (Table Name () sys_).refindex. tablename get: The record owning the field (Record Id () sys_).refindex. recuid get: The TCA field name (Field Name () sys_).refindex. field get: The referenced table (Reference Table () sys_).refindex. ref_ table get: The referenced record ID (Reference Id () sys_).refindex. ref_ uid get: TheAction () \TYPO3\enum value (CMS\ Workspaces\ Dependency\ Dependency Collection Action Publish,Stage,Change Discard, orDisplay).get: The current workspace ID.Workspace Id () is/Dependency () set: Read or change whether this reference is a structural dependency.Dependency ()
TYPO3 Core registers a listener that marks
type=inline,
type=file (with
foreign_), and
type=flex fields as
dependencies.
A new enum
\TYPO3\
has been added to represent the action context.
Example
A third-party extension that stores parent-child relationships in a custom field can register a listener to include those references as workspace dependencies:
namespace Vendor\MyPackage\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Workspaces\Event\
IsReferenceConsideredForDependencyEvent;
#[AsEventListener('my-package/workspace-dependency')]
final class WorkspaceDependencyListener
{
public function __invoke(
IsReferenceConsideredForDependencyEvent $event
): void {
if ($event->getFieldName() === 'tx_mypackage_parent') {
$event->setDependency(true);
}
}
}
Impact
Extensions can now register custom parent-child relationships as workspace dependencies via this PSR-14 event. This ensures that structurally dependent records are published, staged, or discarded together, preventing orphaned records in workspaces.
The internal pseudo-event mechanism (Event,
Element) that was previously used has been removed. This is an
internal change that does not affect the public API.