Skip to content

Commit

Permalink
feat: require flysystem v3
Browse files Browse the repository at this point in the history
  • Loading branch information
augustas committed Aug 28, 2024
1 parent d16dd31 commit 233b6e6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 19 deletions.
2 changes: 1 addition & 1 deletion common/oatbox/filesystem/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getRelPath($content)
*/
public function exists()
{
return $this->getFileSystem()->has($this->getPrefix());
return $this->getFileSystem()->directoryExists($this->getPrefix());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions common/oatbox/filesystem/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getMetadata()
{
try {
$path = $this->getPrefix();
if ($this->getFileSystem()->has($path)) {
if ($this->getFileSystem()->fileExists($path)) {
return $this->getFileSystem()->get($path)->getMetadata();
}
} catch (FileNotFoundException $e) {
Expand Down Expand Up @@ -265,7 +265,7 @@ public function exists()
try {
$path = $this->getPrefix();

if ($this->getFileSystem()->has($path)) {
if ($this->getFileSystem()->fileExists($path)) {
$metadata = $this->getFileSystem()->getMetadata($this->getPrefix());
return $metadata['type'] === 'file';
}
Expand Down
73 changes: 57 additions & 16 deletions common/oatbox/filesystem/utils/FileSystemWrapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace oat\oatbox\filesystem\utils;

use League\Flysystem\DirectoryListing;
use League\Flysystem\Filesystem;
use League\Flysystem\Handler;
use League\Flysystem\PluginInterface;
Expand All @@ -36,19 +37,19 @@ trait FileSystemWrapperTrait
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::has()
*/
public function has($path)
public function directoryExists($path)
{
return $this->getFileSystem()->has($this->getFullPath($path));
return $this->getFileSystem()->directoryExists($this->getFullPath($path));
}


/**
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::read()
*/
public function read($path)
public function read(string $location): string
{
return $this->getFileSystem()->read($this->getFullPath($path));
return $this->getFileSystem()->read($this->getFullPath($location));
}


Expand All @@ -66,9 +67,9 @@ public function readStream($path)
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::listContents()
*/
public function listContents($directory = '', $recursive = false)
public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing
{
return $this->getFileSystem()->listContents($this->getFullPath($directory), $recursive);
return $this->getFileSystem()->listContents($this->getFullPath($location), $deep);
}


Expand Down Expand Up @@ -126,19 +127,19 @@ public function getVisibility($path)
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::write()
*/
public function write($path, $contents, array $config = [])
public function write(string $location, string $contents, array $config = []): void
{
return $this->getFileSystem()->write($this->getFullPath($path), $contents, $config);
$this->getFileSystem()->write($this->getFullPath($location), $contents, $config);
}


/**
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::writeStream()
*/
public function writeStream($path, $resource, array $config = [])
public function writeStream(string $location, $contents, array $config = []): void
{
return $this->getFileSystem()->writeStream($this->getFullPath($path), $resource, $config);
$this->getFileSystem()->writeStream($this->getFullPath($location), $contents, $config);
}


Expand Down Expand Up @@ -176,19 +177,19 @@ public function rename($path, $newpath)
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::copy()
*/
public function copy($path, $newpath)
public function copy(string $source, string $destination, array $config = []): void
{
return $this->getFileSystem()->copy($this->getFullPath($path), $newpath);
$this->getFileSystem()->copy($this->getFullPath($source), $destination);
}


/**
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::delete()
*/
public function delete($path)
public function delete(string $location): void
{
return $this->getFileSystem()->delete($this->getFullPath($path));
$this->getFileSystem()->delete($this->getFullPath($location));
}


Expand Down Expand Up @@ -216,9 +217,9 @@ public function createDir($dirname, array $config = [])
* (non-PHPdoc)
* @see \League\Flysystem\FilesystemInterface::setVisibility()
*/
public function setVisibility($path, $visibility)
public function setVisibility(string $path, string $visibility): void
{
return $this->getFileSystem()->setVisibility($this->getFullPath($path), $visibility);
$this->getFileSystem()->setVisibility($this->getFullPath($path), $visibility);
}


Expand Down Expand Up @@ -271,6 +272,46 @@ public function addPlugin(PluginInterface $plugin)
return $this->getFileSystem()->addPlugin($plugin);
}

public function fileExists(string $location): bool
{
return $this->getFileSystem()->fileExists($this->getFullPath($location));
}

public function lastModified(string $path): int
{
return $this->getFileSystem()->lastModified($this->getFullPath($path));
}

public function fileSize(string $path): int
{
return $this->getFileSystem()->fileSize($this->getFullPath($path));
}

public function mimeType(string $path): string
{
return $this->getFileSystem()->mimeType($this->getFullPath($path));
}

public function visibility(string $path): string
{
return $this->getFileSystem()->visibility($this->getFullPath($path));
}

public function deleteDirectory(string $location): void
{
$this->getFileSystem()->deleteDirectory($this->getFullPath($location));
}

public function createDirectory(string $location, array $config = []): void
{
$this->getFileSystem()->createDirectory($this->getFullPath($location), $config);
}

public function move(string $source, string $destination, array $config = []): void
{
$this->getFileSystem()->move($this->getFullPath($source), $destination, $config);
}

/**
* Return the underlying Filesystem
*
Expand Down

0 comments on commit 233b6e6

Please sign in to comment.