TYPO3 CMS  TYPO3_8-7
FolderLinkHandler.php
Go to the documentation of this file.
1 <?php
2 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  */
20 
27 {
28 
33  protected $baseUrn = 't3://folder';
34 
39  protected $resourceFactory;
40 
48  public function asString(array $parameters): string
49  {
50  // the magic with prepending slash if it is missing will not work on windows
51  return $this->baseUrn . '?storage=' . $parameters['folder']->getStorage()->getUid() .
52  '&identifier=' . urlencode('/' . ltrim($parameters['folder']->getIdentifier(), '/'));
53  }
54 
62  public function resolveHandlerData(array $data): array
63  {
64  $combinedIdentifier = ($data['storage'] ?? '0') . ':' . $data['identifier'];
65  try {
66  $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
67  } catch (FolderDoesNotExistException $e) {
68  $folder = null;
69  }
70  return ['folder' => $folder];
71  }
72 
78  protected function getResourceFactory(): ResourceFactory
79  {
80  if (!$this->resourceFactory) {
81  $this->resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
82  }
84  }
85 }
static makeInstance($className,... $constructorArguments)