2 namespace TYPO3\CMS\Core\Resource;
30 protected $objectType = \TYPO3\CMS\Core\Resource\ResourceStorage::class;
35 protected $table =
'sys_file_storage';
59 parent::__construct();
62 $logManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class);
63 $this->logger = $logManager->getLogger(__CLASS__);
75 if (isset(self::$storageRowCache[$uid])) {
76 return $this->factory->getStorageObject($uid, self::$storageRowCache[$uid]);
89 if (static::$storageRowCache === null) {
90 static::$storageRowCache = $this->db->exec_SELECTgetRows(
104 if (static::$storageRowCache === array()) {
105 $storageObjectsExists = $this->db->exec_SELECTgetSingleRow(
'uid', $this->table,
'');
106 if ($storageObjectsExists !== null) {
107 if ($this->createLocalStorage(
108 'fileadmin/ (auto-created)',
109 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
111 'This is the local fileadmin/ directory. This storage mount has been created automatically by TYPO3.',
115 static::$storageRowCache = null;
130 public function findByStorageType($storageType)
135 $driverRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class);
137 $storageObjects = array();
138 foreach (static::$storageRowCache as $storageRow) {
139 if ($storageRow[
'driver'] !== $storageType) {
142 if ($driverRegistry->driverExists($storageRow[
'driver'])) {
143 $storageObjects[] = $this->factory->getStorageObject($storageRow[
'uid'], $storageRow);
145 $this->logger->warning(
146 sprintf(
'Could not instantiate storage "%s" because of missing driver.', array($storageRow[
'name'])),
151 return $storageObjects;
165 $driverRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class);
167 $storageObjects = array();
168 foreach (static::$storageRowCache as $storageRow) {
169 if ($driverRegistry->driverExists($storageRow[
'driver'])) {
170 $storageObjects[] = $this->factory->getStorageObject($storageRow[
'uid'], $storageRow);
172 $this->logger->warning(
173 sprintf(
'Could not instantiate storage "%s" because of missing driver.', array($storageRow[
'name'])),
178 return $storageObjects;
191 public function createLocalStorage($name, $basePath, $pathType, $description =
'', $default =
false)
193 $caseSensitive = $this->
testCaseSensitivity($pathType ===
'relative' ? PATH_site . $basePath : $basePath);
195 $flexFormData = array(
199 'basePath' => array(
'vDEF' => rtrim($basePath,
'/') .
'/'),
200 'pathType' => array(
'vDEF' => $pathType),
201 'caseSensitive' => array(
'vDEF' => $caseSensitive)
208 $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class);
209 $flexFormXml = $flexObj->flexArray2Xml($flexFormData,
true);
212 $field_values = array(
217 'description' => $description,
219 'configuration' => $flexFormXml,
224 'is_default' => $default ? 1 : 0
226 $this->db->exec_INSERTquery(
'sys_file_storage', $field_values);
227 return (
int)$this->db->sql_insert_id();
238 return $this->factory->getStorageObject($databaseRow[
'uid'], $databaseRow);
249 $caseSensitive =
true;
250 $path = rtrim($absolutePath,
'/') .
'/aAbB';
251 $testFileExists = @file_exists($path);
254 if (!$testFileExists) {
259 if (@file_exists(strtoupper($path)) && @file_exists(strtolower($path))) {
260 $caseSensitive =
false;
264 if (!$testFileExists) {
268 return $caseSensitive;