本文整理汇总了PHP中League\Flysystem\Filesystem::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::delete方法的具体用法?PHP Filesystem::delete怎么用?PHP Filesystem::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Remove file or a directory
*
* @param $path
* @return void
*/
public function remove($path)
{
if (!$this->filesystem->has($path)) {
return;
}
$meta = $this->filesystem->getMetadata($path);
if ($meta['type'] === 'file') {
$this->filesystem->delete($path);
} else {
$this->filesystem->deleteDir($path);
}
}
示例2: remove
/**
* Removes a value from the cache.
*
* @param string $key A unique key
*
* @return bool True on success, false on failure.
*/
public function remove($key)
{
try {
return $this->filesystem->delete($key);
} catch (FileNotFoundException $exception) {
return false;
}
}
示例3: write
protected function write($data)
{
$destination = $this->composer->getClassPath($this->data['name']);
if ($this->force && $this->external->has($destination)) {
$this->external->delete($destination);
}
return $this->external->write($destination, $data);
}
示例4: remove
/**
* {@inheritdoc}
*/
public function remove(File $file) : bool
{
$key = $file->getKey();
if ($this->filesystem->has($key)) {
return $this->filesystem->delete($key);
}
return true;
}
示例5:
function it_should_execute_the_delete_old_files_command(Filesystem $filesystem, DateTime $olderThan)
{
$filesystem->listWith(['timestamp'], '/dir', false)->willReturn([['path' => '/dir/file-new.gz', 'timestamp' => 2000], ['path' => '/dir/file-old.gz', 'timestamp' => 1000], ['path' => '/dir/file-older.gz', 'timestamp' => 500]]);
$olderThan->getTimestamp()->willReturn(1500);
$filesystem->delete('/dir/file-older.gz')->shouldBeCalled();
$filesystem->delete('/dir/file-old.gz')->shouldBeCalled();
$this->beConstructedWith($filesystem, '/dir', $olderThan);
$this->execute();
}
示例6: execute
/**
* @return bool
*/
public function execute()
{
$files = $this->filesystem->listWith(['timestamp'], $this->directoryPath, false);
foreach ($files as $file) {
if ($file['timestamp'] < $this->olderThan->getTimestamp()) {
$this->filesystem->delete($file['path']);
}
}
}
示例7: unpublish
/**
* @param File $file
* @param Version $version
* @param VersionProvider $versionProvider
* @param Linker $linker
* @return bool
*/
public function unpublish(File $file, Version $version, VersionProvider $versionProvider, Linker $linker)
{
$path = $linker->getLink($file, $version, $versionProvider->getExtension($file, $version));
if (!$this->filesystem->has($path)) {
return false;
}
$this->filesystem->delete($path);
return true;
}
示例8: unlink
/**
* {@inheritdoc}
*/
public function unlink($path) {
if ($this->is_dir($path)) {
return $this->rmdir($path);
}
try {
return $this->flysystem->delete($this->buildPath($path));
} catch (FileNotFoundException $e) {
return false;
}
}
示例9: execute
/**
* @return bool
*/
public function execute()
{
if ($this->filesystem->getMimetype($this->filePath) == 'application/x-gzip') {
if ($this->filesystem->getMimetype(str_replace('.tar.gz', '', $this->filePath)) == 'directory') {
$this->filesystem->deleteDir(str_replace('.tar.gz', '', $this->filePath));
}
}
if ($this->filesystem->getMimetype($this->filePath) == 'directory') {
return $this->filesystem->deleteDir($this->filePath);
} else {
return $this->filesystem->delete($this->filePath);
}
}
示例10: handleField
protected function handleField(Request $request, $item, array $fields, $groupName, $fieldName)
{
$modelFolder = $this->slug . DIRECTORY_SEPARATOR;
$basePath = base_path(DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . config('anavel-crud.uploads_path'));
$modelPath = $basePath . $modelFolder;
$skip = null;
$requestValue = null;
if (!empty($fields["{$fieldName}__delete"])) {
//We never want to save this field, it doesn't exist in the DB
$skip = "{$fieldName}__delete";
//If user wants to delete the existing file
if (!empty($request->input("{$groupName}.{$fieldName}__delete"))) {
$adapter = new Local($basePath);
$filesystem = new Filesystem($adapter);
if ($filesystem->has($item->{$fieldName})) {
$filesystem->delete($item->{$fieldName});
}
$item->setAttribute($fieldName, null);
return ['skip' => $skip];
}
}
if ($request->hasFile($groupName . '.' . $fieldName)) {
$fileName = uniqid() . '.' . $request->file($groupName . '.' . $fieldName)->getClientOriginalExtension();
$request->file($groupName . '.' . $fieldName)->move($modelPath, $fileName);
$requestValue = $modelFolder . $fileName;
} elseif (!empty($request->file($groupName . '.' . $fieldName)) && !$request->file($groupName . '.' . $fieldName)->isValid()) {
throw new \Exception($request->file($groupName . '.' . $fieldName)->getErrorMessage());
}
return ['requestValue' => $requestValue, 'skip' => $skip];
}
示例11: generate
public function generate()
{
if (PHP_SAPI != 'cli') {
throw new \Exception("This script only can be used in CLI");
}
$config = $this->config->get('database');
system(sprintf('/usr/bin/mysqldump -u %s -h %s -p%s -r /tmp/phosphorum.sql %s', $config->username, $config->host, $config->password, $config->dbname));
system('bzip2 -f /tmp/phosphorum.sql');
$config = $this->config->get('dropbox');
if (!$config instanceof Config) {
throw new \Exception("Unable to retrieve Dropbox credentials. Please check Forum Configuration");
}
if (!$config->get('appSecret') || !$config->get('accessToken')) {
throw new \Exception("Please provide correct 'appSecret' and 'accessToken' config values");
}
$sourcePath = '/tmp/phosphorum.sql.bz2';
if (!file_exists($sourcePath)) {
throw new \Exception("Backup could not be created");
}
$client = new Client($config->get('accessToken'), $config->get('appSecret'));
$adapter = new DropboxAdapter($client, $config->get('prefix', null));
$filesystem = new Filesystem($adapter);
$dropboxPath = '/phosphorum.sql.bz2';
if ($filesystem->has($dropboxPath)) {
$filesystem->delete($dropboxPath);
}
$fp = fopen($sourcePath, "rb");
$filesystem->putStream($dropboxPath, $fp);
fclose($fp);
@unlink($sourcePath);
}
示例12: get
/**
* Get cached string from store.
*
* @param string $key
*
* @return null|string
*/
public function get($key)
{
if (!is_string($key)) {
return;
}
try {
$file = $this->get_file_name($key);
// Expire the file if the expires time is not zero.
if ($this->args['expires'] > 0) {
$time = $this->filesystem->getTimestamp($file);
// If time is bigger than expires and file timestamp
// the file should be deleted and null should be returned
// since the cache has expired.
if (time() > $this->args['expires'] * $time) {
$this->filesystem->delete($file);
return;
}
}
// Try to read the file.
$content = $this->filesystem->read($file);
// Delete the file if empty.
if (empty($content)) {
$this->filesystem->delete($file);
}
return $content;
} catch (FileNotFoundException $e) {
return;
}
}
示例13: deleteVersion
public function deleteVersion(Versionable $versionable, Version $version)
{
$ret = $this->filesystem->delete($this->getVersionPathName($versionable, $version));
if (!$ret) {
throw new FileIOException(sprintf("Failed to delete version '%s' of versionable %s;%s", $version->toString(), get_class($versionable), $versionable->getId()));
}
}
示例14: tearDown
/**
* Cleanup output files after each test
*/
public function tearDown()
{
$cleanup = ['sprite.jpg', 'sprite.vtt', 'blubber.jpg', 'blubber.vtt'];
foreach ($cleanup as $file) {
$this->outputFS->has($file) && $this->outputFS->delete($file);
}
}
示例15: process
/**
* Process give source file with given options
*
* @param array $options
* @param $sourceFile
* @return string
*/
public function process($options, $sourceFile)
{
//check restricted_domains is enabled
if ($this->params['restricted_domains'] && is_array($this->params['whitelist_domains']) && !in_array(parse_url($sourceFile, PHP_URL_HOST), $this->params['whitelist_domains'])) {
throw new \Exception('Restricted domains enabled, the domain your fetching from is not allowed: ' . parse_url($sourceFile, PHP_URL_HOST));
}
$options = $this->parseOptions($options);
$newFileName = md5(implode('.', $options) . $sourceFile);
if ($this->filesystem->has($newFileName) && $options['refresh']) {
$this->filesystem->delete($newFileName);
}
if (!$this->filesystem->has($newFileName)) {
$this->saveNewFile($sourceFile, $newFileName, $options);
}
return $this->filesystem->read($newFileName);
}