Update Composer packages
This commit is contained in:
parent
67c3d8b307
commit
83cb211fe6
219 changed files with 6487 additions and 4444 deletions
|
@ -3,6 +3,8 @@
|
|||
namespace Kirby\Filesystem;
|
||||
|
||||
use Kirby\Cms\FileModifications;
|
||||
use Kirby\Cms\HasMethods;
|
||||
use Kirby\Exception\BadMethodCallException;
|
||||
|
||||
/**
|
||||
* Anything in your public path can be converted
|
||||
|
@ -20,6 +22,7 @@ class Asset
|
|||
{
|
||||
use IsFile;
|
||||
use FileModifications;
|
||||
use HasMethods;
|
||||
|
||||
/**
|
||||
* Relative file path
|
||||
|
@ -38,6 +41,31 @@ class Asset
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller for asset methods
|
||||
*
|
||||
* @throws \Kirby\Exception\BadMethodCallException
|
||||
*/
|
||||
public function __call(string $method, array $arguments = [])
|
||||
{
|
||||
// public property access
|
||||
if (isset($this->$method) === true) {
|
||||
return $this->$method;
|
||||
}
|
||||
|
||||
// asset method proxy
|
||||
if (method_exists($this->asset(), $method)) {
|
||||
return $this->asset()->$method(...$arguments);
|
||||
}
|
||||
|
||||
// asset methods
|
||||
if ($this->hasMethod($method)) {
|
||||
return $this->callMethod($method, $arguments);
|
||||
}
|
||||
|
||||
throw new BadMethodCallException('The method: "' . $method . '" does not exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique id for the asset
|
||||
*/
|
||||
|
|
|
@ -48,12 +48,16 @@ class Dir
|
|||
|
||||
/**
|
||||
* Copy the directory to a new destination
|
||||
*
|
||||
* @param array|false $ignore List of full paths to skip during copying
|
||||
* or `false` to copy all files, including
|
||||
* those listed in `Dir::$ignore`
|
||||
*/
|
||||
public static function copy(
|
||||
string $dir,
|
||||
string $target,
|
||||
bool $recursive = true,
|
||||
array $ignore = []
|
||||
array|false $ignore = []
|
||||
): bool {
|
||||
if (is_dir($dir) === false) {
|
||||
throw new Exception('The directory "' . $dir . '" does not exist');
|
||||
|
@ -67,10 +71,13 @@ class Dir
|
|||
throw new Exception('The target directory "' . $target . '" could not be created');
|
||||
}
|
||||
|
||||
foreach (static::read($dir) as $name) {
|
||||
foreach (static::read($dir, $ignore === false ? [] : null) as $name) {
|
||||
$root = $dir . '/' . $name;
|
||||
|
||||
if (in_array($root, $ignore) === true) {
|
||||
if (
|
||||
is_array($ignore) === true &&
|
||||
in_array($root, $ignore) === true
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -132,19 +139,32 @@ class Dir
|
|||
|
||||
/**
|
||||
* Read the directory and all subdirectories
|
||||
*
|
||||
* @todo Remove support for `$ignore = null` in a major release
|
||||
* @param array|false|null $ignore Array of absolut file paths;
|
||||
* `false` to disable `Dir::$ignore` list
|
||||
* (passing null is deprecated)
|
||||
*/
|
||||
public static function index(
|
||||
string $dir,
|
||||
bool $recursive = false,
|
||||
array|null $ignore = null,
|
||||
array|false|null $ignore = [],
|
||||
string $path = null
|
||||
): array {
|
||||
$result = [];
|
||||
$dir = realpath($dir);
|
||||
$items = static::read($dir);
|
||||
$items = static::read($dir, $ignore === false ? [] : null);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$root = $dir . '/' . $item;
|
||||
$root = $dir . '/' . $item;
|
||||
|
||||
if (
|
||||
is_array($ignore) === true &&
|
||||
in_array($root, $ignore) === true
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$entry = $path !== null ? $path . '/' . $item : $item;
|
||||
$result[] = $entry;
|
||||
|
||||
|
|
|
@ -514,7 +514,14 @@ class F
|
|||
static::remove($newRoot);
|
||||
}
|
||||
|
||||
// actually move the file if it exists
|
||||
$directory = dirname($newRoot);
|
||||
|
||||
// create the parent directory if it does not exist
|
||||
if (is_dir($directory) === false) {
|
||||
Dir::make($directory, true);
|
||||
}
|
||||
|
||||
// actually move the file
|
||||
if (rename($oldRoot, $newRoot) !== true) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue