Upgrade to 3.9.2

This commit is contained in:
Bastian Allgeier
2023-03-08 12:24:06 +01:00
parent c58864a585
commit 3b0b4feb16
44 changed files with 672 additions and 201 deletions

View File

@@ -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
*/

View File

@@ -57,7 +57,7 @@ class Dir
string $dir,
string $target,
bool $recursive = true,
array|bool $ignore = []
array|false $ignore = []
): bool {
if (is_dir($dir) === false) {
throw new Exception('The directory "' . $dir . '" does not exist');
@@ -139,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;