[BUGFIX] Root-level folders cannot be displayed
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / ResourceFactory.php
index 62da3d9..8d4c15e 100644 (file)
@@ -48,22 +48,22 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
-        * @var t3lib_file_Storage[]
+        * @var \TYPO3\CMS\Core\Resource\ResourceStorage[]
         */
        protected $storageInstances = array();
 
        /**
-        * @var t3lib_file_AbstractCollection[]
+        * @var \TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection[]
         */
        protected $collectionInstances = array();
 
        /**
-        * @var t3lib_file_File[]
+        * @var \TYPO3\CMS\Core\Resource\File[]
         */
        protected $fileInstances = array();
 
        /**
-        * @var t3lib_file_FileReference[]
+        * @var \TYPO3\CMS\Core\Resource\FileReference[]
         */
        protected $fileReferenceInstances = array();
 
@@ -73,7 +73,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
         * @param string $driverIdentificationString The driver class (or identifier) to use.
         * @param array $driverConfiguration The configuration of the storage
         * @return \TYPO3\CMS\Core\Resource\Driver\AbstractDriver
-        * @throws InvalidArgumentException
+        * @throws \InvalidArgumentException
         */
        public function getDriverObject($driverIdentificationString, array $driverConfiguration) {
                /** @var $driverRegistry \TYPO3\CMS\Core\Resource\Driver\DriverRegistry */
@@ -168,7 +168,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        // Get mount data if not already supplied as argument to this function
                        if (count($recordData) === 0 || $recordData['uid'] !== $uid) {
                                /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
-                               $recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_collection', ('uid=' . intval($uid)) . ' AND deleted=0');
+                               $recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_collection', 'uid=' . intval($uid) . ' AND deleted=0');
                                if (!is_array($recordData)) {
                                        throw new \InvalidArgumentException('No collection found for given UID.', 1314085992);
                                }
@@ -253,7 +253,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        // Fetches data in case $fileData is empty
                        if (empty($fileData)) {
                                /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
-                               $fileData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file', ('uid=' . intval($uid)) . ' AND deleted=0');
+                               $fileData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file', 'uid=' . intval($uid) . ' AND deleted=0');
                                if (!is_array($fileData)) {
                                        throw new \InvalidArgumentException('No file found for given UID.', 1317178604);
                                }
@@ -301,7 +301,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
         * - "file:23"
         *
         * @param string $input
-        * @return t3lib_file_FileInterface|t3lib_file_Folder
+        * @return \TYPO3\CMS\Core\Resource\FileInterface|\TYPO3\CMS\Core\Resource\Folder
         */
        public function retrieveFileOrFolderObject($input) {
                // Easy function to deal with that, could be dropped in the future
@@ -348,11 +348,26 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                return $this->getStorageObject($storageUid)->getFolder($folderIdentifier);
        }
 
+       /**
+        * Gets a storage object from a combined identifier
+        *
+        * @param string $identifier An identifier of the form [storage uid]:[object identifier]
+        * @return \TYPO3\CMS\Core\Resource\ResourceStorage
+        */
+       public function getStorageObjectFromCombinedIdentifier($identifier) {
+               $parts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $identifier);
+               if (count($parts) === 2) {
+                       $storageUid = $parts[0];
+               }
+
+               return $this->getStorageObject($storageUid);
+       }
+
        /**
         * Gets a file or folder object.
         *
         * @param string $identifier
-        * @return t3lib_file_FileInterface|t3lib_file_Folder
+        * @return \TYPO3\CMS\Core\Resource\FileInterface|\TYPO3\CMS\Core\Resource\Folder
         */
        public function getObjectFromCombinedIdentifier($identifier) {
                list($storageId, $objectIdentifier) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $identifier);
@@ -362,7 +377,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                } elseif ($storage->hasFolder($objectIdentifier)) {
                        return $storage->getFolder($objectIdentifier);
                } else {
-                       throw new \RuntimeException(('Object with identifier "' . $identifier) . '" does not exist in storage', 1329647780);
+                       throw new \RuntimeException('Object with identifier "' . $identifier . '" does not exist in storage', 1329647780);
                }
        }
 
@@ -405,7 +420,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                                        $fileReferenceData = $GLOBALS['TSFE']->sys_page->checkRecord('sys_file_reference', $uid);
                                } else {
                                        /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
-                                       $fileReferenceData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_reference', ('uid=' . intval($uid)) . ' AND deleted=0');
+                                       $fileReferenceData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_reference', 'uid=' . intval($uid) . ' AND deleted=0');
                                }
                                if (!is_array($fileReferenceData)) {
                                        throw new \InvalidArgumentException('No fileusage (sys_file_reference) found for given UID.', 1317178794);
@@ -431,7 +446,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
-        * Generates a new object of the type t3lib_file_ProcessedFile
+        * Generates a new object of the type \TYPO3\CMS\Core\Resource\ProcessedFile
         * additionally checks if this processed file already exists in the DB
         *
         * @param \TYPO3\CMS\Core\Resource\FileInterface $originalFileObject
@@ -442,7 +457,7 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
        public function getProcessedFileObject(\TYPO3\CMS\Core\Resource\FileInterface $originalFileObject, $context, array $configuration) {
                /** @var \TYPO3\CMS\Core\Resource\ProcessedFile $processedFileObject */
                $processedFileObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ProcessedFile', $originalFileObject, $context, $configuration);
-               /* @var t3lib_file_Repository_ProcessedFileRepository $repository */
+               /* @var \TYPO3\CMS\Core\Resource\ProcessedFileRepository $repository */
                $repository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ProcessedFileRepository');
                // Check if this file already exists in the DB
                $repository->populateDataOfProcessedFileObject($processedFileObject);