*/ class Import extends Record { public function findLinked(string $id, string $link, SearchParams $searchParams): RecordCollection { if (!in_array($link, ['imported', 'duplicates', 'updated'])) { return parent::findLinked($id, $link, $searchParams); } /** @var ImportEntity $entity */ $entity = $this->getImportRepository()->get($id); $foreignEntityType = $entity->get('entityType'); if (!$this->acl->check($entity, 'read')) { throw new Forbidden(); } if (!$this->acl->check($foreignEntityType, 'read')) { throw new Forbidden(); } $query = $this->selectBuilderFactory ->create() ->from($foreignEntityType) ->withStrictAccessControl() ->withSearchParams($searchParams) ->build(); /** @var \Espo\ORM\Collection<\Espo\ORM\Entity> */ $collection = $this->getImportRepository()->findResultRecords($entity, $link, $query); $listLoadProcessor = $this->injectableFactory->create(ListLoadProcessor::class); $recordService = $this->recordServiceContainer->get($foreignEntityType); foreach ($collection as $e) { $listLoadProcessor->process($e); $recordService->prepareEntityForOutput($e); } $total = $this->getImportRepository()->countResultRecords($entity, $link, $query); return new RecordCollection($collection, $total); } private function getImportRepository(): Repository { /** @var Repository */ return $this->getRepository(); } }