本文整理汇总了PHP中TYPO3\CMS\Core\Resource\Folder::createFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::createFolder方法的具体用法?PHP Folder::createFolder怎么用?PHP Folder::createFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\Folder
的用法示例。
在下文中一共展示了Folder::createFolder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeSysFileResourceForLegacyImport
/**
* Writes the file with the is $fileId to the legacy import folder. The file name will used from
* argument $fileName and the file was successfully created or an identical file was already found,
* $fileName will held the uid of the new created file record.
*
* @param string $fileName The file name for the new file. Value would be changed to the uid of the new created file record.
* @param int $fileId The id of the file in data array
* @return bool
*/
protected function writeSysFileResourceForLegacyImport(&$fileName, $fileId)
{
if ($this->legacyImportFolder === null) {
return false;
}
if (!isset($this->dat['files'][$fileId])) {
$this->error('ERROR: File ID "' . $fileId . '" could not be found');
return false;
}
$temporaryFile = $this->writeTemporaryFileFromData($fileId, 'files');
if ($temporaryFile === null) {
// error on writing the file. Error message was already added
return false;
}
$importFolder = $this->legacyImportFolder;
if (isset($this->dat['files'][$fileId]['relFileName'])) {
$relativeFilePath = PathUtility::dirname($this->dat['files'][$fileId]['relFileName']);
if (!$this->legacyImportFolder->hasFolder($relativeFilePath)) {
$this->legacyImportFolder->createFolder($relativeFilePath);
}
$importFolder = $this->legacyImportFolder->getSubfolder($relativeFilePath);
}
$fileObject = null;
try {
// check, if there is alreay the same file in the folder
if ($importFolder->hasFile($fileName)) {
$fileStorage = $importFolder->getStorage();
$file = $fileStorage->getFile($importFolder->getIdentifier() . $fileName);
if ($file->getSha1() === sha1_file($temporaryFile)) {
$fileObject = $file;
}
}
} catch (Exception $e) {
}
if ($fileObject === null) {
try {
$fileObject = $importFolder->addFile($temporaryFile, $fileName, DuplicationBehavior::RENAME);
} catch (Exception $e) {
$this->error('Error: no file could be added to the storage for file name ' . $this->alternativeFileName[$temporaryFile]);
}
}
if (md5_file(PATH_site . $fileObject->getPublicUrl()) == $this->dat['files'][$fileId]['content_md5']) {
$fileName = $fileObject->getUid();
$this->fileIDMap[$fileId] = $fileName;
$this->filePathMap[$fileId] = $fileObject->getPublicUrl();
return true;
} else {
$this->error('ERROR: File content "' . $this->dat['files'][$fileId]['relFileName'] . '" was corrupted');
}
return false;
}