Upgrade to 4.0.0

This commit is contained in:
Bastian Allgeier
2023-11-28 09:33:56 +01:00
parent f96b96af76
commit 3b0b6546ca
480 changed files with 21371 additions and 13327 deletions

View File

@@ -17,18 +17,22 @@ class FileVersion
{
use IsFile;
protected $modifications;
protected array $modifications;
protected $original;
public function __construct(array $props)
{
$this->root = $props['root'] ?? null;
$this->url = $props['url'] ?? null;
$this->original = $props['original'];
$this->modifications = $props['modifications'] ?? [];
}
/**
* Proxy for public properties, asset methods
* and content field getters
*
* @param string $method
* @param array $arguments
* @return mixed
*/
public function __call(string $method, array $arguments = [])
public function __call(string $method, array $arguments = []): mixed
{
// public property access
if (isset($this->$method) === true) {
@@ -52,8 +56,6 @@ class FileVersion
/**
* Returns the unique ID
*
* @return string
*/
public function id(): string
{
@@ -62,30 +64,24 @@ class FileVersion
/**
* Returns the parent Kirby App instance
*
* @return \Kirby\Cms\App
*/
public function kirby()
public function kirby(): App
{
return $this->original()->kirby();
}
/**
* Returns an array with all applied modifications
*
* @return array
*/
public function modifications(): array
{
return $this->modifications ?? [];
return $this->modifications;
}
/**
* Returns the instance of the original File object
*
* @return mixed
*/
public function original()
public function original(): mixed
{
return $this->original;
}
@@ -96,7 +92,7 @@ class FileVersion
*
* @return $this
*/
public function save()
public function save(): static
{
$this->kirby()->thumb(
$this->original()->root(),
@@ -106,36 +102,16 @@ class FileVersion
return $this;
}
/**
* Setter for modifications
*
* @param array|null $modifications
*/
protected function setModifications(array $modifications = null)
{
$this->modifications = $modifications;
}
/**
* Setter for the original File object
*
* @param $original
*/
protected function setOriginal($original)
{
$this->original = $original;
}
/**
* Converts the object to an array
*
* @return array
*/
public function toArray(): array
{
$array = array_merge($this->asset()->toArray(), [
'modifications' => $this->modifications(),
]);
$array = array_merge(
$this->asset()->toArray(),
['modifications' => $this->modifications()]
);
ksort($array);