‪TYPO3CMS  10.4
FolderLinkHandler.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 
24 
31 {
32 
37  protected ‪$baseUrn = 't3://folder';
38 
43  protected ‪$resourceFactory;
44 
52  public function ‪asString(array $parameters): string
53  {
54  // the magic with prepending slash if it is missing will not work on windows
55  return $this->baseUrn . '?storage=' . $parameters['folder']->getStorage()->getUid() .
56  '&identifier=' . urlencode('/' . ltrim($parameters['folder']->getIdentifier(), '/'));
57  }
58 
66  public function ‪resolveHandlerData(array $data): array
67  {
68  $combinedIdentifier = ($data['storage'] ?? '0') . ':' . $data['identifier'];
69  try {
70  $folder = $this->‪getResourceFactory()->‪getFolderObjectFromCombinedIdentifier($combinedIdentifier);
72  $folder = null;
73  }
74  return ['folder' => $folder];
75  }
76 
82  protected function ‪getResourceFactory(): ‪ResourceFactory
83  {
84  if (!$this->resourceFactory) {
85  $this->resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
86  }
88  }
89 }
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\ResourceFactory\getFolderObjectFromCombinedIdentifier
‪Folder getFolderObjectFromCombinedIdentifier($identifier)
Definition: ResourceFactory.php:530
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException
Definition: FolderDoesNotExistException.php:22
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46