17 use Psr\Log\LoggerAwareInterface;
18 use Psr\Log\LoggerAwareTrait;
45 protected $table =
'sys_file_storage';
65 if (isset($this->storageRowCache[$uid])) {
66 return $this->factory->getStorageObject($uid, $this->storageRowCache[$uid]);
82 if (!isset($this->storageRowCache[$uid])) {
83 throw new \InvalidArgumentException(sprintf(
'No storage found with uid "%d".', $uid), 1599235454);
86 return $this->storageRowCache[$uid];
94 if ($this->storageRowCache ===
null) {
95 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
96 ->getQueryBuilderForTable($this->table);
99 $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
102 $result = $queryBuilder
108 $this->storageRowCache = [];
109 while ($row = $result->fetch()) {
110 if (!empty($row[
'uid'])) {
111 $this->storageRowCache[$row[
'uid']] = $row;
120 if ($this->storageRowCache === []) {
121 $connection = GeneralUtility::makeInstance(ConnectionPool::class)
122 ->getConnectionForTable($this->table);
124 $storageObjectsCount = $connection->count(
'uid', $this->table, []);
126 if ($storageObjectsCount === 0) {
128 'fileadmin/ (auto-created)',
129 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
131 'This is the local fileadmin/ directory. This storage mount has been created automatically by TYPO3.',
135 $this->storageRowCache =
null;
155 $driverRegistry = GeneralUtility::makeInstance(Driver\DriverRegistry::class);
157 $storageObjects = [];
158 foreach ($this->storageRowCache as $storageRow) {
159 if ($storageRow[
'driver'] !== $storageType) {
162 if ($driverRegistry->driverExists($storageRow[
'driver'])) {
163 $storageObjects[] = $this->factory->getStorageObject($storageRow[
'uid'], $storageRow);
165 $this->logger->warning(
166 sprintf(
'Could not instantiate storage "%s" because of missing driver.', [$storageRow[
'name']]),
171 return $storageObjects;
185 $driverRegistry = GeneralUtility::makeInstance(Driver\DriverRegistry::class);
187 $storageObjects = [];
188 foreach ($this->storageRowCache as $storageRow) {
189 if ($driverRegistry->driverExists($storageRow[
'driver'])) {
190 $storageObjects[] = $this->factory->getStorageObject($storageRow[
'uid'], $storageRow);
192 $this->logger->warning(
193 sprintf(
'Could not instantiate storage "%s" because of missing driver.', [$storageRow[
'name']]),
198 return $storageObjects;
211 public function createLocalStorage($name, $basePath, $pathType, $description =
'', $default =
false)
219 'basePath' => [
'vDEF' => rtrim($basePath,
'/') .
'/'],
220 'pathType' => [
'vDEF' => $pathType],
221 'caseSensitive' => [
'vDEF' => $caseSensitive]
228 $flexObj = GeneralUtility::makeInstance(FlexFormTools::class);
229 $flexFormXml = $flexObj->flexArray2Xml($flexFormData,
true);
237 'description' => $description,
239 'configuration' => $flexFormXml,
244 'is_default' => $default ? 1 : 0
247 $dbConnection = GeneralUtility::makeInstance(ConnectionPool::class)
248 ->getConnectionForTable($this->table);
249 $dbConnection->insert($this->table, $field_values);
252 $this->storageRowCache =
null;
254 return (
int)$dbConnection->lastInsertId($this->table);
265 return $this->factory->getStorageObject($databaseRow[
'uid'], $databaseRow);
276 $caseSensitive =
true;
277 $path = rtrim($absolutePath,
'/') .
'/aAbB';
278 $testFileExists = @file_exists($path);
281 if (!$testFileExists) {
286 if (@file_exists(strtoupper($path)) && @file_exists(strtolower($path))) {
287 $caseSensitive =
false;
291 if (!$testFileExists) {
295 return $caseSensitive;