getUid(); // I am not sure about this use case. Maybe if the file was not indexed and saved to DB (migration from old systems) if ($uid > 0) { $urn = '?uid=' . $uid; } else { $identifier = $parameters['file']->getIdentifier(); $urn = '?identifier=' . urlencode($identifier); } if (!empty($parameters['fragment'])) { $urn .= '#' . $parameters['fragment']; } return $this->baseUrn . $urn; } /** * Get a file object inside the array data from the string * * @param array $data with the "file" property containing a File object * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException */ public function resolveHandlerData(array $data): array { try { $file = $this->resolveFile($data); $fileNameValidator = GeneralUtility::makeInstance(FileNameValidator::class); if ($file !== null && (!$fileNameValidator->isValid(basename($file->getIdentifier())) || !$fileNameValidator->isValid($file->getName())) ) { $file = null; } } catch (FileDoesNotExistException $e) { $file = null; } $result = ['file' => $file]; if (!empty($data['fragment'])) { $result['fragment'] = $data['fragment']; } return $result; } /** * @throws FileDoesNotExistException */ protected function resolveFile(array $data): ?FileInterface { if (is_numeric($data['uid'] ?? false)) { return $this->getResourceFactory()->getFileObject($data['uid']); } if (is_string($data['identifier'] ?? false) && $data['identifier'] !== '') { return $this->getResourceFactory()->getFileObjectFromCombinedIdentifier($data['identifier']); } return null; } /** * Initializes the resource factory (only once) */ protected function getResourceFactory(): ResourceFactory { return $this->resourceFactory ??= GeneralUtility::makeInstance(ResourceFactory::class); } }