TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
FileHandlingUtility Class Reference
Inheritance diagram for FileHandlingUtility:
SingletonInterface

Public Member Functions

 injectEmConfUtility (\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility $emConfUtility)
 
 injectInstallUtility (\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility)
 
 injectLanguageService (\TYPO3\CMS\Lang\LanguageService $languageService)
 
 initializeObject ()
 
 unpackExtensionFromExtensionDataArray (array $extensionData, Extension $extension=null, $pathType= 'Local')
 
 getExtensionDir ($extensionKey, $pathType= 'Local')
 
 ensureConfiguredDirectoriesExist (array $extension)
 
 removeDirectory ($extDirPath)
 
 isValidExtensionPath ($path)
 
 getAbsoluteExtensionPath ($extension)
 
 getExtensionVersion ($extension)
 
 createZipFileFromExtension ($extension)
 
 unzipExtensionFromFile ($file, $fileName, $pathType= 'Local')
 
 sendZipFileToBrowserAndDelete ($fileName, $downloadName= '')
 
 sendSqlDumpFileToBrowserAndDelete ($fileName, $downloadName= '')
 

Protected Member Functions

 extractDirectoriesFromExtensionData (array $files)
 
 extractFilesArrayFromExtensionData (array $extensionData)
 
 createDirectoriesForExtensionFiles (array $directories, $rootPath)
 
 createNestedDirectory ($directory)
 
 writeExtensionFiles (array $files, $rootPath)
 
 makeAndClearExtensionDir ($extensionKey, $pathType= 'Local')
 
 addDirectory ($extDirPath)
 
 directoryExists ($directory)
 
 getAbsolutePathsToConfiguredDirectories (array $extension)
 
 getPathToUploadFolder ($extension)
 
 writeEmConfToFile (array $extensionData, $rootPath, Extension $extension=null)
 
 getAbsolutePath ($relativePath)
 
 getRelativePath ($absolutePath)
 
 reloadPackageInformation ($extensionKey)
 

Protected Attributes

 $emConfUtility
 
 $installUtility
 
 $languageService
 

Detailed Description

Utility for dealing with files and folders

Definition at line 25 of file FileHandlingUtility.php.

Member Function Documentation

addDirectory (   $extDirPath)
protected

Add specified directory

Parameters
string$extDirPath
Exceptions
ExtensionManagerException
Returns
void

Definition at line 221 of file FileHandlingUtility.php.

References FileHandlingUtility\getRelativePath(), and GeneralUtility\mkdir().

Referenced by FileHandlingUtility\makeAndClearExtensionDir().

createDirectoriesForExtensionFiles ( array  $directories,
  $rootPath 
)
protected

Loops over an array of directories and creates them in the given root path It also creates nested directory structures

Parameters
array$directories
string$rootPath
Returns
void

Definition at line 133 of file FileHandlingUtility.php.

References FileHandlingUtility\createNestedDirectory().

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray().

createNestedDirectory (   $directory)
protected

Wrapper for utility method to create directory recusively

Parameters
string$directoryAbsolute path
Exceptions
ExtensionManagerException

Definition at line 146 of file FileHandlingUtility.php.

References FileHandlingUtility\getRelativePath(), and GeneralUtility\mkdir_deep().

Referenced by FileHandlingUtility\createDirectoriesForExtensionFiles(), and FileHandlingUtility\ensureConfiguredDirectoriesExist().

createZipFileFromExtension (   $extension)
directoryExists (   $directory)
protected

Wrapper method for directory existence check

Parameters
string$directory
Returns
bool

Definition at line 252 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\ensureConfiguredDirectoriesExist().

ensureConfiguredDirectoriesExist ( array  $extension)

Creates directories configured in ext_emconf.php if not already present

Parameters
array$extension

Definition at line 237 of file FileHandlingUtility.php.

References FileHandlingUtility\createNestedDirectory(), FileHandlingUtility\directoryExists(), and FileHandlingUtility\getAbsolutePathsToConfiguredDirectories().

extractDirectoriesFromExtensionData ( array  $files)
protected

Extract needed directories from given extensionDataFilesArray

Parameters
array$files
Returns
array

Definition at line 102 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray().

extractFilesArrayFromExtensionData ( array  $extensionData)
protected

Returns the "FILES" part from the data array

Parameters
array$extensionData
Returns
mixed

Definition at line 120 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray().

getAbsoluteExtensionPath (   $extension)

Get extension path for an available or installed extension

Parameters
string$extension
Returns
string

Definition at line 391 of file FileHandlingUtility.php.

References FileHandlingUtility\getAbsolutePath().

Referenced by FileHandlingUtility\createZipFileFromExtension().

getAbsolutePath (   $relativePath)
protected

Returns absolute path

Parameters
string$relativePath
Exceptions
ExtensionManagerException
Returns
string

Definition at line 365 of file FileHandlingUtility.php.

References GeneralUtility\getFileAbsFileName(), and GeneralUtility\resolveBackPath().

Referenced by FileHandlingUtility\createZipFileFromExtension(), FileHandlingUtility\getAbsoluteExtensionPath(), and FileHandlingUtility\getAbsolutePathsToConfiguredDirectories().

getAbsolutePathsToConfiguredDirectories ( array  $extension)
protected

Checks configuration and returns an array of absolute paths that should be created

Parameters
array$extension
Returns
array

Definition at line 263 of file FileHandlingUtility.php.

References FileHandlingUtility\getAbsolutePath(), FileHandlingUtility\getPathToUploadFolder(), and GeneralUtility\trimExplode().

Referenced by FileHandlingUtility\ensureConfiguredDirectoriesExist().

getExtensionDir (   $extensionKey,
  $pathType = 'Local' 
)

Returns the installation directory for an extension depending on the installation scope

Parameters
string$extensionKey
string$pathTypeExtension installation scope (Local,Global,System)
Returns
string
Exceptions
ExtensionManagerException

Definition at line 200 of file FileHandlingUtility.php.

References FileHandlingUtility\getRelativePath(), and Extension\returnInstallPaths().

Referenced by FileHandlingUtility\makeAndClearExtensionDir().

getExtensionVersion (   $extension)

Get version of an available or installed extension

Parameters
string$extension
Returns
string

Definition at line 404 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\createZipFileFromExtension().

getPathToUploadFolder (   $extension)
protected

Upload folders always reside in “uploads/tx_[extKey-with-no-underscore]”

Parameters
array$extension
Returns
string

Definition at line 287 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\getAbsolutePathsToConfiguredDirectories().

getRelativePath (   $absolutePath)
protected
initializeObject ( )

Initialize method - loads language file

Returns
void

Definition at line 71 of file FileHandlingUtility.php.

injectEmConfUtility ( \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility  $emConfUtility)
Parameters
\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility$emConfUtility

Definition at line 45 of file FileHandlingUtility.php.

References FileHandlingUtility\$emConfUtility.

injectInstallUtility ( \TYPO3\CMS\Extensionmanager\Utility\InstallUtility  $installUtility)
Parameters
\TYPO3\CMS\Extensionmanager\Utility\InstallUtility$installUtility

Definition at line 53 of file FileHandlingUtility.php.

References FileHandlingUtility\$installUtility.

injectLanguageService ( \TYPO3\CMS\Lang\LanguageService  $languageService)
Parameters
\TYPO3\CMS\Lang\LanguageService$languageService

Definition at line 61 of file FileHandlingUtility.php.

References FileHandlingUtility\$languageService.

isValidExtensionPath (   $path)

Is the given path a valid path for extension installation

Parameters
string$paththe absolute (!) path in question
Returns
bool

Definition at line 347 of file FileHandlingUtility.php.

References GeneralUtility\isFirstPartOfStr(), and Extension\returnAllowedInstallPaths().

makeAndClearExtensionDir (   $extensionKey,
  $pathType = 'Local' 
)
protected

Removes the current extension of $type and creates the base folder for the new one (which is going to be imported)

Parameters
string$extensionKey
string$pathTypeExtension installation scope (Local,Global,System)
Exceptions
ExtensionManagerException
Returns
string

Definition at line 181 of file FileHandlingUtility.php.

References FileHandlingUtility\addDirectory(), FileHandlingUtility\getExtensionDir(), and FileHandlingUtility\removeDirectory().

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray(), and FileHandlingUtility\unzipExtensionFromFile().

reloadPackageInformation (   $extensionKey)
protected
Parameters
string$extensionKey

Definition at line 552 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray().

removeDirectory (   $extDirPath)

Remove specified directory

Parameters
string$extDirPath
Exceptions
ExtensionManagerException
Returns
void

Definition at line 299 of file FileHandlingUtility.php.

References GeneralUtility\fixWindowsFilePath(), FileHandlingUtility\getRelativePath(), and GeneralUtility\rmdir().

Referenced by FileHandlingUtility\makeAndClearExtensionDir().

sendSqlDumpFileToBrowserAndDelete (   $fileName,
  $downloadName = '' 
)

Sends the sql dump file to the browser and deletes it afterwards

Parameters
string$fileName
string$downloadName
Returns
void

Definition at line 534 of file FileHandlingUtility.php.

sendZipFileToBrowserAndDelete (   $fileName,
  $downloadName = '' 
)

Sends a zip file to the browser and deletes it afterwards

Parameters
string$fileName
string$downloadName
Returns
void

Definition at line 514 of file FileHandlingUtility.php.

unpackExtensionFromExtensionDataArray ( array  $extensionData,
Extension  $extension = null,
  $pathType = 'Local' 
)
unzipExtensionFromFile (   $file,
  $fileName,
  $pathType = 'Local' 
)

Unzip an extension.zip.

Parameters
string$filepath to zip file
string$fileNamefile name
string$pathTypepath type (Local, Global, System)
Exceptions
ExtensionManagerException
Returns
void

Definition at line 479 of file FileHandlingUtility.php.

References FileHandlingUtility\getRelativePath(), FileHandlingUtility\makeAndClearExtensionDir(), GeneralUtility\mkdir_deep(), and GeneralUtility\writeFile().

writeEmConfToFile ( array  $extensionData,
  $rootPath,
Extension  $extension = null 
)
protected

Constructs emConf and writes it to corresponding file In case the file has been extracted already, the properties of the meta data take precedence but are merged with the present ext_emconf.php

Parameters
array$extensionData
string$rootPath
Extension$extension
Returns
void

Definition at line 325 of file FileHandlingUtility.php.

References PathUtility\stripPathSitePrefix(), and GeneralUtility\writeFile().

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray().

writeExtensionFiles ( array  $files,
  $rootPath 
)
protected

Loops over an array of files and writes them to the given rootPath

Parameters
array$files
string$rootPath
Returns
void

Definition at line 165 of file FileHandlingUtility.php.

References GeneralUtility\writeFile().

Referenced by FileHandlingUtility\unpackExtensionFromExtensionDataArray().

Member Data Documentation

$emConfUtility
protected

Definition at line 30 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\injectEmConfUtility().

$installUtility
protected

Definition at line 35 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\injectInstallUtility().

$languageService
protected

Definition at line 40 of file FileHandlingUtility.php.

Referenced by FileHandlingUtility\injectLanguageService().