*/ class CommentsEntityEventListener implements IEventListener { public function __construct( private IRootFolder $rootFolder, private ?string $userId = null, ) { } public function handle(Event $event): void { if (!($event instanceof CommentsEntityEvent)) { // Unrelated return; } if ($this->userId === null) { return; } $event->addEntityCollection('files', function ($name): bool { $node = $this->rootFolder->getUserFolder($this->userId)->getFirstNodeById((int)$name); return $node !== null; }); } }