‪TYPO3CMS  ‪main
FileLinktype.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 
30 {
31  protected string ‪$identifier = 'file';
32 
41  public function ‪fetchType(array $value, string $type, string $key): string
42  {
43  if (str_starts_with(strtolower((string)$value['tokenValue']), 'file:')) {
44  $type = 'file';
45  }
46  return $type;
47  }
48 
57  public function ‪checkLink(string ‪$url, array $softRefEntry, ‪LinkAnalyzer $reference): bool
58  {
59  $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
60  try {
61  $file = $resourceFactory->retrieveFileOrFolderObject(‪$url);
63  return false;
64  }
65 
66  return ($file !== null) ? !$file->isMissing() : false;
67  }
68 
75  public function ‪getErrorMessage(array ‪$errorParams): string
76  {
77  return $this->‪getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:list.report.filenotexisting');
78  }
79 
86  public function ‪getBrokenUrl(array $row): string
87  {
88  return ‪$GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getSiteUrl() . $row['url'];
89  }
90 }
‪TYPO3\CMS\Linkvalidator\Linktype\FileLinktype\getErrorMessage
‪string getErrorMessage(array $errorParams)
Definition: FileLinktype.php:75
‪TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype\$errorParams
‪array $errorParams
Definition: AbstractLinktype.php:32
‪TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
Definition: FileDoesNotExistException.php:21
‪TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype
Definition: AbstractLinktype.php:26
‪TYPO3\CMS\Linkvalidator\Linktype\FileLinktype\getBrokenUrl
‪string getBrokenUrl(array $row)
Definition: FileLinktype.php:86
‪TYPO3\CMS\Linkvalidator\Linktype\FileLinktype\$identifier
‪string $identifier
Definition: FileLinktype.php:31
‪TYPO3\CMS\Linkvalidator\Linktype\FileLinktype\fetchType
‪string fetchType(array $value, string $type, string $key)
Definition: FileLinktype.php:41
‪TYPO3\CMS\Linkvalidator\Linktype
Definition: AbstractLinktype.php:18
‪TYPO3\CMS\Linkvalidator\Linktype\FileLinktype
Definition: FileLinktype.php:30
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:42
‪TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException
Definition: FolderDoesNotExistException.php:21
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Linkvalidator\Linktype\FileLinktype\checkLink
‪bool checkLink(string $url, array $softRefEntry, LinkAnalyzer $reference)
Definition: FileLinktype.php:57
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype\getLanguageService
‪getLanguageService()
Definition: AbstractLinktype.php:97