‪TYPO3CMS  ‪main
AbstractDriver.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
24 abstract class ‪AbstractDriver implements ‪DriverInterface
25 {
26  /*******************
27  * CAPABILITIES
28  *******************/
35  protected ‪$capabilities = 0;
36 
42  protected ‪$storageUid;
43 
51  protected ‪$supportedHashAlgorithms = [];
52 
58  protected ‪$configuration = [];
59 
63  public function ‪__construct(array ‪$configuration = [])
64  {
65  $this->configuration = ‪$configuration;
66  }
67 
75  protected function ‪isValidFilename($fileName)
76  {
77  if (str_contains($fileName, '/')) {
78  return false;
79  }
80  if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
81  return false;
82  }
83  return true;
84  }
85 
91  public function ‪setStorageUid(‪$storageUid)
92  {
93  $this->storageUid = ‪$storageUid;
94  }
95 
105  public function ‪getCapabilities()
106  {
107  return ‪$this->capabilities;
108  }
109 
116  public function ‪hasCapability($capability)
117  {
118  return ($this->capabilities & $capability) === $capability;
119  }
120 
121  /*******************
122  * FILE FUNCTIONS
123  *******************/
124 
131  protected function ‪getTemporaryPathForFile($fileIdentifier)
132  {
133  return GeneralUtility::tempnam('fal-tempfile-', '.' . ‪PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
134  }
135 
144  public function ‪hashIdentifier(‪$identifier)
145  {
147  return sha1(‪$identifier);
148  }
149 
158  public function ‪sanitizeFileName($fileName, $charset = '')
159  {
160  return $fileName;
161  }
162 
172  public function ‪isCaseSensitiveFileSystem()
173  {
174  if (isset($this->configuration['caseSensitive'])) {
175  return (bool)$this->configuration['caseSensitive'];
176  }
177  return true;
178  }
179 
186  abstract protected function ‪canonicalizeAndCheckFilePath($filePath);
187 
195  abstract protected function ‪canonicalizeAndCheckFileIdentifier($fileIdentifier);
196 
203  abstract protected function ‪canonicalizeAndCheckFolderIdentifier($folderIdentifier);
204 }
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$capabilities
‪int $capabilities
Definition: AbstractDriver.php:34
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$configuration
‪array $configuration
Definition: AbstractDriver.php:54
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getCapabilities
‪int getCapabilities()
Definition: AbstractDriver.php:101
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:23
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hashIdentifier
‪string hashIdentifier($identifier)
Definition: AbstractDriver.php:140
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hasCapability
‪bool hasCapability($capability)
Definition: AbstractDriver.php:112
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\setStorageUid
‪setStorageUid($storageUid)
Definition: AbstractDriver.php:87
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$supportedHashAlgorithms
‪array $supportedHashAlgorithms
Definition: AbstractDriver.php:48
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\isValidFilename
‪bool isValidFilename($fileName)
Definition: AbstractDriver.php:71
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getTemporaryPathForFile
‪non empty string getTemporaryPathForFile($fileIdentifier)
Definition: AbstractDriver.php:127
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFilePath
‪string canonicalizeAndCheckFilePath($filePath)
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFileIdentifier
‪string canonicalizeAndCheckFileIdentifier($fileIdentifier)
‪TYPO3\CMS\Core\Resource\Driver
Definition: AbstractDriver.php:16
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFolderIdentifier
‪string canonicalizeAndCheckFolderIdentifier($folderIdentifier)
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$storageUid
‪int $storageUid
Definition: AbstractDriver.php:40
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\sanitizeFileName
‪string sanitizeFileName($fileName, $charset='')
Definition: AbstractDriver.php:154
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\__construct
‪__construct(array $configuration=[])
Definition: AbstractDriver.php:59
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string string[] pathinfo(string $path, int $options=PATHINFO_ALL)
Definition: PathUtility.php:270
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver
Definition: AbstractDriver.php:25
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\isCaseSensitiveFileSystem
‪bool isCaseSensitiveFileSystem()
Definition: AbstractDriver.php:168