本文整理汇总了PHP中TYPO3\CMS\Core\Resource\FileInterface::getParentFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP FileInterface::getParentFolder方法的具体用法?PHP FileInterface::getParentFolder怎么用?PHP FileInterface::getParentFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\FileInterface
的用法示例。
在下文中一共展示了FileInterface::getParentFolder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPath
/**
* @return string
*/
public function getPath()
{
$method = 'getReadablePath';
if (is_callable([$this->resource->getParentFolder(), $method])) {
return call_user_func([$this->resource->getParentFolder(), $method]);
}
return '';
}
示例2: moveFile
/**
* Moves a $file into a $targetFolder
* the target folder has to be part of this storage
*
* previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_move()
*
* @param FileInterface $file
* @param Folder $targetFolder
* @param string $targetFileName an optional destination fileName
* @param string $conflictMode a value of the DuplicationBehavior enumeration
*
* @throws Exception\ExistingTargetFileNameException
* @throws \RuntimeException
* @return FileInterface
*/
public function moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME)
{
$conflictMode = DuplicationBehavior::cast($conflictMode);
if ($targetFileName === null) {
$targetFileName = $file->getName();
}
$originalFolder = $file->getParentFolder();
$sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
$this->assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName);
if ($targetFolder->hasFile($sanitizedTargetFileName)) {
// File exists and we should abort, let's abort
if ($conflictMode->equals(DuplicationBehavior::RENAME)) {
$sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName);
} elseif ($conflictMode->equals(DuplicationBehavior::CANCEL)) {
throw new Exception\ExistingTargetFileNameException('The target file already exists', 1329850997);
}
}
$this->emitPreFileMoveSignal($file, $targetFolder);
$sourceStorage = $file->getStorage();
// Call driver method to move the file and update the index entry
try {
if ($sourceStorage === $this) {
$newIdentifier = $this->driver->moveFileWithinStorage($file->getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName);
if (!$file instanceof AbstractFile) {
throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025);
}
$file->updateProperties(array('identifier' => $newIdentifier));
} else {
$tempPath = $file->getForLocalProcessing();
$newIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName);
$sourceStorage->driver->deleteFile($file->getIdentifier());
if ($file instanceof File) {
$file->updateProperties(array('storage' => $this->getUid(), 'identifier' => $newIdentifier));
}
}
$this->getIndexer()->updateIndexEntry($file);
} catch (\TYPO3\CMS\Core\Exception $e) {
echo $e->getMessage();
}
$this->emitPostFileMoveSignal($file, $targetFolder, $originalFolder);
return $file;
}
示例3: preFileDelete
/**
* Pre file delete
*
* @param FileInterface $file The file
*
* @return void
*/
public function preFileDelete(FileInterface $file)
{
$this->flushCacheForAffectedPages($file->getParentFolder());
}