Update Kirby and dependencies

This commit is contained in:
Paul Nicoué 2022-08-31 15:02:43 +02:00
parent 503b339974
commit 399fa20902
439 changed files with 66915 additions and 64442 deletions

View file

@ -18,100 +18,100 @@ use Kirby\Cms\FileModifications;
*/
class Asset
{
use IsFile;
use FileModifications;
use IsFile;
use FileModifications;
/**
* Relative file path
*
* @var string
*/
protected $path;
/**
* Relative file path
*
* @var string
*/
protected $path;
/**
* Creates a new Asset object for the given path.
*
* @param string $path
*/
public function __construct(string $path)
{
$this->setProperties([
'path' => dirname($path),
'root' => $this->kirby()->root('index') . '/' . $path,
'url' => $this->kirby()->url('index') . '/' . $path
]);
}
/**
* Creates a new Asset object for the given path.
*
* @param string $path
*/
public function __construct(string $path)
{
$this->setProperties([
'path' => dirname($path),
'root' => $this->kirby()->root('index') . '/' . $path,
'url' => $this->kirby()->url('base') . '/' . $path
]);
}
/**
* Returns a unique id for the asset
*
* @return string
*/
public function id(): string
{
return $this->root();
}
/**
* Returns a unique id for the asset
*
* @return string
*/
public function id(): string
{
return $this->root();
}
/**
* Create a unique media hash
*
* @return string
*/
public function mediaHash(): string
{
return crc32($this->filename()) . '-' . $this->modified();
}
/**
* Create a unique media hash
*
* @return string
*/
public function mediaHash(): string
{
return crc32($this->filename()) . '-' . $this->modified();
}
/**
* Returns the relative path starting at the media folder
*
* @return string
*/
public function mediaPath(): string
{
return 'assets/' . $this->path() . '/' . $this->mediaHash() . '/' . $this->filename();
}
/**
* Returns the relative path starting at the media folder
*
* @return string
*/
public function mediaPath(): string
{
return 'assets/' . $this->path() . '/' . $this->mediaHash() . '/' . $this->filename();
}
/**
* Returns the absolute path to the file in the public media folder
*
* @return string
*/
public function mediaRoot(): string
{
return $this->kirby()->root('media') . '/' . $this->mediaPath();
}
/**
* Returns the absolute path to the file in the public media folder
*
* @return string
*/
public function mediaRoot(): string
{
return $this->kirby()->root('media') . '/' . $this->mediaPath();
}
/**
* Returns the absolute Url to the file in the public media folder
*
* @return string
*/
public function mediaUrl(): string
{
return $this->kirby()->url('media') . '/' . $this->mediaPath();
}
/**
* Returns the absolute Url to the file in the public media folder
*
* @return string
*/
public function mediaUrl(): string
{
return $this->kirby()->url('media') . '/' . $this->mediaPath();
}
/**
* Returns the path of the file from the web root,
* excluding the filename
*
* @return string
*/
public function path(): string
{
return $this->path;
}
/**
* Returns the path of the file from the web root,
* excluding the filename
*
* @return string
*/
public function path(): string
{
return $this->path;
}
/**
* Setter for the path
*
* @param string $path
* @return $this
*/
protected function setPath(string $path)
{
$this->path = $path === '.' ? '' : $path;
return $this;
}
/**
* Setter for the path
*
* @param string $path
* @return $this
*/
protected function setPath(string $path)
{
$this->path = $path === '.' ? '' : $path;
return $this;
}
}