本文整理汇总了PHP中League\Flysystem\FilesystemInterface::deleteDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::deleteDir方法的具体用法?PHP FilesystemInterface::deleteDir怎么用?PHP FilesystemInterface::deleteDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::deleteDir方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean
/** @inheritdoc */
public function clean($validPackages)
{
foreach (Linq::from($this->filesystem->listContents($this->vendorDir))->where(function ($v) {
return $v['type'] == 'dir';
}) as $vendor) {
if (!Linq::from($validPackages)->any(function ($v, $k) use($vendor) {
return preg_match('/^' . $vendor['basename'] . '/i', $k);
})) {
$this->notify("DELETING: " . $vendor['path'] . "\n");
$this->filesystem->deleteDir($vendor['path']);
continue;
}
foreach (Linq::from($this->filesystem->listContents($vendor['path']))->where(function ($v) {
return $v['type'] == 'dir';
}) as $package) {
if (!Linq::from($validPackages)->any(function ($v, $k) use($vendor, $package) {
return $k == $vendor['basename'] . '/' . $package['basename'];
})) {
$this->notify("DELETING: " . $package['path'] . "\n");
$this->filesystem->deleteDir($package['path']);
continue;
}
foreach (Linq::from($this->filesystem->listContents($package['path']))->where(function ($v) {
return $v['type'] == 'dir';
}) as $version) {
if (!Linq::from($validPackages[$vendor['basename'] . '/' . $package['basename']])->any(function ($v) use($version) {
return $v == $version['basename'];
})) {
$this->notify("DELETING: " . $version['path'] . "\n");
$this->filesystem->deleteDir($version['path']);
}
}
}
}
}
示例2: uploadImagePreview
public function uploadImagePreview(int $themeId, string $path) : string
{
$theme = $this->getThemeById($themeId);
$dir = $theme->getId();
$name = sprintf('%s.png', GenerateRandomString::gen(self::GENERATE_FILENAME_LENGTH));
$newPath = sprintf('%s/%s', $dir, $name);
if ($this->fileSystem->has($dir)) {
$this->fileSystem->deleteDir($dir);
}
$this->fileSystem->write($newPath, file_get_contents($path));
$theme->setPreview($newPath);
$this->themeRepository->saveTheme($theme);
return $theme->getPreview();
}
示例3: deleteCache
/**
* Delete cached manipulations for an image.
* @param string $path Image path.
* @return bool Whether the delete succeeded.
*/
public function deleteCache($path)
{
if (!$this->groupCacheInFolders) {
throw new InvalidArgumentException('Deleting cached image manipulations is not possible when grouping cache into folders is disabled.');
}
return $this->cache->deleteDir(dirname($this->getCachePath($path)));
}
示例4: deleteFolder
/**
* Removes a folder in filesystem.
*
* @param string $folderIdentifier
* @param bool $deleteRecursively
* @return bool
* @throws FileOperationErrorException
*/
public function deleteFolder($folderIdentifier, $deleteRecursively = false)
{
$folderIdentifier = ltrim($folderIdentifier, '/');
$result = $this->filesystem->deleteDir($folderIdentifier);
if (false === $result) {
throw new FileOperationErrorException('Deleting folder "' . $folderIdentifier . '" failed.', 1330119451);
}
return $result;
}
示例5: extract
/** @inheritdoc */
public function extract($zipBallPath, $to)
{
$absolutePathToZipBall = $this->filesystem->getAdapter()->applyPathPrefix($zipBallPath);
if ($this->zip->open($absolutePathToZipBall) === true) {
$absolutePathToExtract = $this->filesystem->getAdapter()->applyPathPrefix($to);
$this->zip->extractTo($absolutePathToExtract);
$this->zip->close();
$zipCreatedFolder = Linq::from($this->filesystem->listContents($to))->single(function ($object) {
return $object['type'] == 'dir';
})['path'];
foreach ($this->filesystem->listContents($zipCreatedFolder, true) as $object) {
if ($object['type'] == "file") {
$segments = explode('/', $object['path']);
unset($segments[4]);
$this->filesystem->rename($object['path'], implode('/', $segments));
}
}
$this->filesystem->deleteDir($zipCreatedFolder);
return;
}
throw new ZipExtractionFailed($zipBall, $to);
}
示例6: removeEmptyDirectories
/**
* {@inheritdoc}
*/
protected function removeEmptyDirectories($backupName)
{
/**
* @var \SplFileInfo $dir
*/
foreach ($this->flysystem->listContents($backupName) as $dir) {
if ($dir['type'] != 'dir') {
continue;
}
if (count($this->flysystem->listContents($dir['path'])) > 0) {
$this->removeEmptyDirectories($dir['path']);
} else {
$this->flysystem->deleteDir($dir['path']);
}
}
}
示例7: eraseDir
/**
* Erase a directory.
*
* @param string $dirname
* @throws IoWriteException
*/
public function eraseDir($dirname = '')
{
try {
$listing = $this->fs->listContents($dirname, false);
foreach ($listing as $item) {
if ($item['type'] === 'dir') {
$this->fs->deleteDir($item['path']);
} else {
$this->fs->delete($item['path']);
}
}
} catch (Error $ex) {
throw new IoWriteException("Directory {$dirname} could not be erased.", $ex);
} catch (Exception $ex) {
throw new IoWriteException("Directory {$dirname} could not be erased.", $ex);
}
}
示例8: ensuredEraseDir
/**
* Erase a directory.
*
* @param string $dirname
* @throws WriteException
*/
private function ensuredEraseDir($dirname)
{
try {
$listing = $this->fs->listContents($dirname, false);
foreach ($listing as $item) {
if ($item['type'] === 'dir') {
$this->fs->deleteDir($item['path']);
} else {
$this->fs->delete($item['path']);
}
}
return;
} catch (Error $ex) {
} catch (Exception $ex) {
}
throw new WriteException("Directory {$dirname} could not be erased.", $ex);
}
示例9: deleteDirectory
/**
* Recursively delete a directory.
*
* @param string $directory
* @return bool
*/
public function deleteDirectory($directory)
{
return $this->driver->deleteDir($directory);
}
示例10: _rmdir
/**
* Remove dir
*
* @param string $path dir path
* @return bool
**/
protected function _rmdir($path)
{
return $this->fs->deleteDir($path);
}
示例11: deleteDirectory
public function deleteDirectory($spiPath)
{
$this->filesystem->deleteDir($spiPath);
}
示例12: deleteCache
/**
* Delete cached manipulations for an image.
* @param string $path Image path.
* @return bool Whether the delete succeeded.
*/
public function deleteCache($path)
{
return $this->cache->deleteDir(dirname($this->getCachePath($path)));
}
示例13: delete
/**
* @param \livetyping\hermitage\foundation\entities\Image $image
*
* @throws \livetyping\hermitage\foundation\exceptions\ImageNotFoundException
*/
public function delete(Image $image)
{
$this->assertPresent($image->getPath());
$this->filesystem->deleteDir($image->getDirname());
}
示例14: deleteDir
/**
* Delete a directory.
*
* @param string $dirname
*
* @throws RootViolationException Thrown if $dirname is empty.
*
* @return bool True on success, false on failure.
*/
public function deleteDir($dirname)
{
return $this->fileSystem->deleteDir($dirname);
}