mirror of
https://github.com/getgrav/grav.git
synced 2026-05-09 12:38:10 +02:00
Flex improvements
This commit is contained in:
@@ -332,7 +332,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
public function getMetaData(string $key): array
|
||||
public function getMetaData($key): array
|
||||
{
|
||||
return $this->getEntries()[$key] ?? [];
|
||||
}
|
||||
|
||||
@@ -240,8 +240,4 @@ trait PageAuthorsTrait
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
abstract public function getNestedProperty($property, $default = null, $separator = null);
|
||||
|
||||
abstract protected function loadAccounts();
|
||||
}
|
||||
|
||||
@@ -500,15 +500,9 @@ trait PageContentTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param Header|stdClass|array|null $value
|
||||
* @return Header
|
||||
*/
|
||||
abstract public function exists(): bool;
|
||||
|
||||
abstract public function getProperty($property, $default = null);
|
||||
abstract public function setProperty($property, $value);
|
||||
abstract public function &getArrayProperty($property, $default = null, $doCreate = false);
|
||||
|
||||
|
||||
protected function offsetLoad_header($value)
|
||||
{
|
||||
if ($value instanceof Header) {
|
||||
|
||||
@@ -1107,33 +1107,4 @@ trait PageLegacyTrait
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $namespace
|
||||
* @return CacheInterface
|
||||
*/
|
||||
abstract public function getCache(string $namespace = null);
|
||||
|
||||
/**
|
||||
* @param PageInterface|null $var
|
||||
* @return PageInterface|null
|
||||
*/
|
||||
abstract public function parent(PageInterface $var = null);
|
||||
|
||||
abstract public function getFlexDirectory(): FlexDirectory;
|
||||
|
||||
abstract protected function exists(): bool;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
abstract protected function getStorageFolder();
|
||||
|
||||
/**
|
||||
* @param string $property
|
||||
* @param mixed $var
|
||||
* @param callable $filter
|
||||
* @return mixed|null
|
||||
*/
|
||||
abstract protected function loadHeaderProperty(string $property, $var, callable $filter);
|
||||
}
|
||||
|
||||
@@ -545,6 +545,4 @@ trait PageRoutableTrait
|
||||
|
||||
return $this->root === true || $this->getKey() === '/';
|
||||
}
|
||||
|
||||
abstract protected function loadHeaderProperty(string $property, $var, callable $filter);
|
||||
}
|
||||
|
||||
@@ -280,6 +280,4 @@ trait PageTranslateTrait
|
||||
|
||||
return $fallback ? $language->getFallbackLanguages($languageCode, true) : [$languageCode];
|
||||
}
|
||||
|
||||
abstract protected function loadHeaderProperty(string $property, $var, callable $filter);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ class SimpleStorage extends AbstractFilesystemStorage
|
||||
protected $dataPattern;
|
||||
/** @var string */
|
||||
protected $prefix;
|
||||
/** @var array */
|
||||
/** @var array|null */
|
||||
protected $data;
|
||||
/** @var int */
|
||||
protected $modified;
|
||||
protected $modified = 0;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -76,7 +76,7 @@ class SimpleStorage extends AbstractFilesystemStorage
|
||||
public function clearCache(): void
|
||||
{
|
||||
$this->data = null;
|
||||
$this->modified = null;
|
||||
$this->modified = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,6 +117,10 @@ trait FlexMediaTrait
|
||||
public function checkUploadedMediaFile(UploadedFileInterface $uploadedFile, string $filename = null, string $field = null)
|
||||
{
|
||||
$media = $this->getMedia();
|
||||
if (!$media instanceof MediaUploadInterface) {
|
||||
throw new RuntimeException("Media for {$this->getFlexDirectory()->getFlexType()} doesn't support file uploads.");
|
||||
}
|
||||
|
||||
$media->checkUploadedFile($uploadedFile, $filename, $this->getMediaFieldSettings($field ?? ''));
|
||||
}
|
||||
|
||||
@@ -130,8 +134,12 @@ trait FlexMediaTrait
|
||||
public function uploadMediaFile(UploadedFileInterface $uploadedFile, string $filename = null, string $field = null): void
|
||||
{
|
||||
$media = $this->getMedia();
|
||||
if (!$media instanceof MediaUploadInterface) {
|
||||
throw new RuntimeException("Media for {$this->getFlexDirectory()->getFlexType()} doesn't support file uploads.");
|
||||
}
|
||||
|
||||
$settings = $this->getMediaFieldSettings($field ?? '');
|
||||
$media->checkUploadedFile($uploadedFile, $filename, $settings);
|
||||
$filename = $media->checkUploadedFile($uploadedFile, $filename, $settings);
|
||||
$media->copyUploadedFile($uploadedFile, $filename, $settings);
|
||||
$this->clearMediaCache();
|
||||
}
|
||||
@@ -144,6 +152,10 @@ trait FlexMediaTrait
|
||||
public function deleteMediaFile(string $filename): void
|
||||
{
|
||||
$media = $this->getMedia();
|
||||
if (!$media instanceof MediaUploadInterface) {
|
||||
throw new RuntimeException("Media for {$this->getFlexDirectory()->getFlexType()} doesn't support file uploads.");
|
||||
}
|
||||
|
||||
$media->deleteFile($filename);
|
||||
$this->clearMediaCache();
|
||||
}
|
||||
@@ -165,6 +177,10 @@ trait FlexMediaTrait
|
||||
protected function setUpdatedMedia(array $files): void
|
||||
{
|
||||
$media = $this->getMedia();
|
||||
if (!$media instanceof MediaUploadInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filesystem = Filesystem::getInstance(false);
|
||||
|
||||
$list = [];
|
||||
@@ -263,6 +279,10 @@ trait FlexMediaTrait
|
||||
protected function saveUpdatedMedia(): void
|
||||
{
|
||||
$media = $this->getMedia();
|
||||
if (!$media instanceof MediaUploadInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Upload/delete altered files.
|
||||
/**
|
||||
|
||||
@@ -56,6 +56,4 @@ trait FlexRelatedDirectoryTrait
|
||||
|
||||
return $directory;
|
||||
}
|
||||
|
||||
abstract public function getNestedProperty($property, $default = null, $separator = null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user