updated core to 1.7.15

This commit is contained in:
2021-05-27 18:17:50 +02:00
parent dc1fdf21c9
commit 19ecb285ab
552 changed files with 80743 additions and 16675 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Grav\Common\User\Interfaces\UserInterface;
/**
* Defines authorization checks for Flex Objects.
*/
interface FlexAuthorizeInterface
{
/**
* Check if user is authorized for the action.
*
* Note: There are two deny values: denied (false), not set (null). This allows chaining multiple rules together
* when the previous rules were not matched.
*
* @param string $action
* @param string|null $scope
* @param UserInterface|null $user
* @return bool|null
*/
public function isAuthorized(string $action, string $scope = null, UserInterface $user = null): ?bool;
}

View File

@@ -0,0 +1,144 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Grav\Framework\Flex\Flex;
use Grav\Framework\Object\Interfaces\NestedObjectInterface;
use Grav\Framework\Object\Interfaces\ObjectCollectionInterface;
use Grav\Framework\Flex\FlexDirectory;
use InvalidArgumentException;
/**
* Defines a collection of Flex Objects.
*
* @used-by \Grav\Framework\Flex\FlexCollection
* @since 1.6
* @template T
* @extends ObjectCollectionInterface<string,T>
*/
interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionInterface, NestedObjectInterface
{
/**
* Creates a Flex Collection from an array.
*
* @used-by FlexDirectory::createCollection() Official method to create a Flex Collection.
*
* @param FlexObjectInterface[] $entries Associated array of Flex Objects to be included in the collection.
* @param FlexDirectory $directory Flex Directory where all the objects belong into.
* @param string|null $keyField Key field used to index the collection.
* @return static Returns a new Flex Collection.
*/
public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null);
/**
* Creates a new Flex Collection.
*
* @used-by FlexDirectory::createCollection() Official method to create Flex Collection.
*
* @param FlexObjectInterface[] $entries Associated array of Flex Objects to be included in the collection.
* @param FlexDirectory|null $directory Flex Directory where all the objects belong into.
* @throws InvalidArgumentException
*/
public function __construct(array $entries = [], FlexDirectory $directory = null);
/**
* Search a string from the collection.
*
* @param string $search Search string.
* @param string|string[]|null $properties Properties to search for, defaults to configured properties.
* @param array|null $options Search options, defaults to configured options.
* @return FlexCollectionInterface Returns a Flex Collection with only matching objects.
* @phpstan-return static<T>
* @api
*/
public function search(string $search, $properties = null, array $options = null);
/**
* Sort the collection.
*
* @param array $orderings Pair of [property => 'ASC'|'DESC', ...].
*
* @return FlexCollectionInterface Returns a sorted version from the collection.
* @phpstan-return static<T>
*/
public function sort(array $orderings);
/**
* Filter collection by filter array with keys and values.
*
* @param array $filters
* @return FlexCollectionInterface
* @phpstan-return static<T>
*/
public function filterBy(array $filters);
/**
* Get timestamps from all the objects in the collection.
*
* This method can be used for example in caching.
*
* @return int[] Returns [key => timestamp, ...] pairs.
*/
public function getTimestamps(): array;
/**
* Get storage keys from all the objects in the collection.
*
* @see FlexDirectory::getObject() If you want to get Flex Object from the Flex Directory.
*
* @return string[] Returns [key => storage_key, ...] pairs.
*/
public function getStorageKeys(): array;
/**
* Get Flex keys from all the objects in the collection.
*
* @see Flex::getObjects() If you want to get list of Flex Objects from any Flex Directory.
*
* @return string[] Returns[key => flex_key, ...] pairs.
*/
public function getFlexKeys(): array;
/**
* Return new collection with a different key.
*
* @param string|null $keyField Switch key field of the collection.
* @return FlexCollectionInterface Returns a new Flex Collection with new key field.
* @phpstan-return static<T>
* @api
*/
public function withKeyField(string $keyField = null);
/**
* Get Flex Index from the Flex Collection.
*
* @return FlexIndexInterface Returns a Flex Index from the current collection.
* @phpstan-return FlexIndexInterface<T>
*/
public function getIndex();
/**
* Load all the objects into memory,
*
* @return FlexCollectionInterface
* @phpstan-return static<T>
*/
public function getCollection();
/**
* Get metadata associated to the object
*
* @param string $key Key.
* @return array
*/
public function getMetaData(string $key): array;
}

View File

@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Interfaces\RenderInterface;
/**
* Defines common interface shared with both Flex Objects and Collections.
*
* @used-by \Grav\Framework\Flex\FlexObject
* @since 1.6
*/
interface FlexCommonInterface extends RenderInterface
{
/**
* Get Flex Type of the object / collection.
*
* @return string Returns Flex Type of the collection.
* @api
*/
public function getFlexType(): string;
/**
* Get Flex Directory for the object / collection.
*
* @return FlexDirectory Returns associated Flex Directory.
* @api
*/
public function getFlexDirectory(): FlexDirectory;
/**
* Test whether the feature is implemented in the object / collection.
*
* @param string $name
* @return bool
*/
public function hasFlexFeature(string $name): bool;
/**
* Get full list of features the object / collection implements.
*
* @return array
*/
public function getFlexFeatures(): array;
/**
* Get last updated timestamp for the object / collection.
*
* @return int Returns Unix timestamp.
* @api
*/
public function getTimestamp(): int;
/**
* Get a cache key which is used for caching the object / collection.
*
* @return string Returns cache key.
*/
public function getCacheKey(): string;
/**
* Get cache checksum for the object / collection.
*
* If checksum changes, cache gets invalided.
*
* @return string Returns cache checksum.
*/
public function getCacheChecksum(): string;
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
/**
* Defines Forms for Flex Objects.
*
* @used-by \Grav\Framework\Flex\FlexForm
* @since 1.7
*/
interface FlexDirectoryFormInterface extends FlexFormInterface
{
/**
* Get object associated to the form.
*
* @return FlexObjectInterface Returns Flex Object associated to the form.
* @api
*/
public function getDirectory();
}

View File

@@ -0,0 +1,223 @@
<?php
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Exception;
use Grav\Common\Data\Blueprint;
use Grav\Framework\Cache\CacheInterface;
/**
* Interface FlexDirectoryInterface
* @package Grav\Framework\Flex\Interfaces
*/
interface FlexDirectoryInterface
{
/**
* @return bool
*/
public function isListed(): bool;
/**
* @return bool
*/
public function isEnabled(): bool;
/**
* @return string
*/
public function getFlexType(): string;
/**
* @return string
*/
public function getTitle(): string;
/**
* @return string
*/
public function getDescription(): string;
/**
* @param string|null $name
* @param mixed $default
* @return mixed
*/
public function getConfig(string $name = null, $default = null);
/**
* @param string|null $name
* @param array $options
* @return FlexFormInterface
* @internal
*/
public function getDirectoryForm(string $name = null, array $options = []);
/**
* @return Blueprint
* @internal
*/
public function getDirectoryBlueprint();
/**
* @param string $name
* @param array $data
* @return void
* @throws Exception
* @internal
*/
public function saveDirectoryConfig(string $name, array $data);
/**
* @param string|null $name
* @return string
*/
public function getDirectoryConfigUri(string $name = null): string;
/**
* Returns a new uninitialized instance of blueprint.
*
* Always use $object->getBlueprint() or $object->getForm()->getBlueprint() instead.
*
* @param string $type
* @param string $context
* @return Blueprint
*/
public function getBlueprint(string $type = '', string $context = '');
/**
* @param string $view
* @return string
*/
public function getBlueprintFile(string $view = ''): string;
/**
* Get collection. In the site this will be filtered by the default filters (published etc).
*
* Use $directory->getIndex() if you want unfiltered collection.
*
* @param array|null $keys Array of keys.
* @param string|null $keyField Field to be used as the key.
* @return FlexCollectionInterface
*/
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface;
/**
* Get the full collection of all stored objects.
*
* Use $directory->getCollection() if you want a filtered collection.
*
* @param array|null $keys Array of keys.
* @param string|null $keyField Field to be used as the key.
* @return FlexIndexInterface
*/
public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface;
/**
* Returns an object if it exists. If no arguments are passed (or both of them are null), method creates a new empty object.
*
* Note: It is not safe to use the object without checking if the user can access it.
*
* @param string|null $key
* @param string|null $keyField Field to be used as the key.
* @return FlexObjectInterface|null
*/
public function getObject($key = null, string $keyField = null): ?FlexObjectInterface;
/**
* @param string|null $namespace
* @return CacheInterface
*/
public function getCache(string $namespace = null);
/**
* @return $this
*/
public function clearCache();
/**
* @param string|null $key
* @return string|null
*/
public function getStorageFolder(string $key = null): ?string;
/**
* @param string|null $key
* @return string|null
*/
public function getMediaFolder(string $key = null): ?string;
/**
* @return FlexStorageInterface
*/
public function getStorage(): FlexStorageInterface;
/**
* @param array $data
* @param string $key
* @param bool $validate
* @return FlexObjectInterface
*/
public function createObject(array $data, string $key = '', bool $validate = false): FlexObjectInterface;
/**
* @param array $entries
* @param string|null $keyField
* @return FlexCollectionInterface
*/
public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface;
/**
* @param array $entries
* @param string|null $keyField
* @return FlexIndexInterface
*/
public function createIndex(array $entries, string $keyField = null): FlexIndexInterface;
/**
* @return string
*/
public function getObjectClass(): string;
/**
* @return string
*/
public function getCollectionClass(): string;
/**
* @return string
*/
public function getIndexClass(): string;
/**
* @param array $entries
* @param string|null $keyField
* @return FlexCollectionInterface
*/
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface;
/**
* @param array $entries
* @return FlexObjectInterface[]
* @internal
*/
public function loadObjects(array $entries): array;
/**
* @return void
*/
public function reloadIndex(): void;
/**
* @param string $scope
* @param string $action
* @return string
*/
public function getAuthorizeRule(string $scope, string $action): string;
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Grav\Framework\Form\Interfaces\FormInterface;
use Grav\Framework\Route\Route;
use Serializable;
/**
* Defines Forms for Flex Objects.
*
* @used-by \Grav\Framework\Flex\FlexForm
* @since 1.6
*/
interface FlexFormInterface extends Serializable, FormInterface
{
/**
* Get media task route.
*
* @return string Returns admin route for media tasks.
*/
public function getMediaTaskRoute(): string;
/**
* Get route for uploading files by AJAX.
*
* @return Route|null Returns Route object or null if file uploads are not enabled.
*/
public function getFileUploadAjaxRoute();
/**
* Get route for deleting files by AJAX.
*
* @param string $field Field where the file is associated into.
* @param string $filename Filename for the file.
* @return Route|null Returns Route object or null if file uploads are not enabled.
*/
public function getFileDeleteAjaxRoute($field, $filename);
}

View File

@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Grav\Framework\Flex\FlexDirectory;
/**
* Defines Indexes for Flex Objects.
*
* Flex indexes are similar to database indexes, they contain indexed fields which can be used to quickly look up or
* find the objects without loading them.
*
* @used-by \Grav\Framework\Flex\FlexIndex
* @since 1.6
* @template T
* @extends FlexCollectionInterface<T>
*/
interface FlexIndexInterface extends FlexCollectionInterface
{
/**
* Helper method to create Flex Index.
*
* @used-by FlexDirectory::getIndex() Official method to get Index from a Flex Directory.
*
* @param FlexDirectory $directory Flex directory.
* @return static Returns a new Flex Index.
*/
public static function createFromStorage(FlexDirectory $directory);
/**
* Method to load index from the object storage, usually filesystem.
*
* @used-by FlexDirectory::getIndex() Official method to get Index from a Flex Directory.
*
* @param FlexStorageInterface $storage Flex Storage associated to the directory.
* @return array Returns a list of existing objects [storage_key => [storage_key => xxx, storage_timestamp => 123456, ...]]
*/
public static function loadEntriesFromStorage(FlexStorageInterface $storage): array;
/**
* Return new collection with a different key.
*
* @param string|null $keyField Switch key field of the collection.
* @return static Returns a new Flex Collection with new key field.
* @api
*/
public function withKeyField(string $keyField = null);
/**
* @param string|null $indexKey
* @return array
*/
public function getIndexMap(string $indexKey = null);
}

View File

@@ -0,0 +1,98 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use Countable;
use Grav\Framework\Flex\FlexDirectory;
use RuntimeException;
/**
* Interface FlexInterface
* @package Grav\Framework\Flex\Interfaces
*/
interface FlexInterface extends Countable
{
/**
* @param string $type
* @param string $blueprint
* @param array $config
* @return $this
*/
public function addDirectoryType(string $type, string $blueprint, array $config = []);
/**
* @param FlexDirectory $directory
* @return $this
*/
public function addDirectory(FlexDirectory $directory);
/**
* @param string $type
* @return bool
*/
public function hasDirectory(string $type): bool;
/**
* @param array|string[]|null $types
* @param bool $keepMissing
* @return array<FlexDirectory|null>
*/
public function getDirectories(array $types = null, bool $keepMissing = false): array;
/**
* @param string $type
* @return FlexDirectory|null
*/
public function getDirectory(string $type): ?FlexDirectory;
/**
* @param string $type
* @param array|null $keys
* @param string|null $keyField
* @return FlexCollectionInterface|null
*/
public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface;
/**
* @param array $keys
* @param array $options In addition to the options in getObjects(), following options can be passed:
* collection_class: Class to be used to create the collection. Defaults to ObjectCollection.
* @return FlexCollectionInterface
* @throws RuntimeException
*/
public function getMixedCollection(array $keys, array $options = []): FlexCollectionInterface;
/**
* @param array $keys
* @param array $options Following optional options can be passed:
* types: List of allowed types.
* type: Allowed type if types isn't defined, otherwise acts as default_type.
* default_type: Set default type for objects given without type (only used if key_field isn't set).
* keep_missing: Set to true if you want to return missing objects as null.
* key_field: Key field which is used to match the objects.
* @return array
*/
public function getObjects(array $keys, array $options = []): array;
/**
* @param string $key
* @param string|null $type
* @param string|null $keyField
* @return FlexObjectInterface|null
*/
public function getObject(string $key, string $type = null, string $keyField = null): ?FlexObjectInterface;
/**
* @return int
*/
public function count(): int;
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
/**
* Defines Forms for Flex Objects.
*
* @used-by \Grav\Framework\Flex\FlexForm
* @since 1.7
*/
interface FlexObjectFormInterface extends FlexFormInterface
{
/**
* Get object associated to the form.
*
* @return FlexObjectInterface Returns Flex Object associated to the form.
* @api
*/
public function getObject();
}

View File

@@ -0,0 +1,210 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
use ArrayAccess;
use Grav\Common\Data\Blueprint;
use Grav\Framework\Flex\Flex;
use Grav\Framework\Object\Interfaces\NestedObjectInterface;
use Grav\Framework\Flex\FlexDirectory;
use InvalidArgumentException;
use Psr\Http\Message\UploadedFileInterface;
use RuntimeException;
/**
* Defines Flex Objects.
*
* @used-by \Grav\Framework\Flex\FlexObject
* @since 1.6
*/
interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface, ArrayAccess
{
/**
* Construct a new Flex Object instance.
*
* @used-by FlexDirectory::createObject() Method to create Flex Object.
*
* @param array $elements Array of object properties.
* @param string $key Identifier key for the new object.
* @param FlexDirectory $directory Flex Directory the object belongs into.
* @param bool $validate True if the object should be validated against blueprint.
* @throws InvalidArgumentException
*/
public function __construct(array $elements, $key, FlexDirectory $directory, bool $validate = false);
/**
* Search a string from the object, returns weight between 0 and 1.
*
* Note: If you override this function, make sure you return value in range 0...1!
*
* @used-by FlexCollectionInterface::search() If you want to search a string from a Flex Collection.
*
* @param string $search Search string.
* @param string|string[]|null $properties Properties to search for, defaults to configured properties.
* @param array|null $options Search options, defaults to configured options.
* @return float Returns a weight between 0 and 1.
* @api
*/
public function search(string $search, $properties = null, array $options = null): float;
/**
* Returns true if object has a key.
*
* @return bool
*/
public function hasKey();
/**
* Get a unique key for the object.
*
* Flex Keys can be used without knowing the Directory the Object belongs into.
*
* @see Flex::getObject() If you want to get Flex Object from any Flex Directory.
* @see Flex::getObjects() If you want to get list of Flex Objects from any Flex Directory.
*
* NOTE: Please do not override the method!
*
* @return string Returns Flex Key of the object.
* @api
*/
public function getFlexKey(): string;
/**
* Get an unique storage key (within the directory) which is used for figuring out the filename or database id.
*
* @see FlexDirectory::getObject() If you want to get Flex Object from the Flex Directory.
* @see FlexDirectory::getCollection() If you want to get Flex Collection with selected keys from the Flex Directory.
*
* @return string Returns storage key of the Object.
* @api
*/
public function getStorageKey(): string;
/**
* Get index data associated to the object.
*
* @return array Returns metadata of the object.
*/
public function getMetaData(): array;
/**
* Returns true if the object exists in the storage.
*
* @return bool Returns `true` if the object exists, `false` otherwise.
* @api
*/
public function exists(): bool;
/**
* Prepare object for saving into the storage.
*
* @return array Returns an array of object properties containing only scalars and arrays.
*/
public function prepareStorage(): array;
/**
* Updates object in the memory.
*
* @see FlexObjectInterface::save() You need to save the object after calling this method.
*
* @param array $data Data containing updated properties with their values. To unset a value, use `null`.
* @param array|UploadedFileInterface[] $files List of uploaded files to be saved within the object.
* @return static
* @throws RuntimeException
* @api
*/
public function update(array $data, array $files = []);
/**
* Create new object into the storage.
*
* @see FlexDirectory::createObject() If you want to create a new object instance.
* @see FlexObjectInterface::update() If you want to update properties of the object.
*
* @param string|null $key Optional new key. If key isn't given, random key will be associated to the object.
* @return static
* @throws RuntimeException if object already exists.
* @api
*/
public function create(string $key = null);
/**
* Save object into the storage.
*
* @see FlexObjectInterface::update() If you want to update properties of the object.
*
* @return static
* @api
*/
public function save();
/**
* Delete object from the storage.
*
* @return static
* @api
*/
public function delete();
/**
* Returns the blueprint of the object.
*
* @see FlexObjectInterface::getForm()
* @used-by FlexForm::getBlueprint()
*
* @param string $name Name of the Blueprint form. Used to create customized forms for different use cases.
* @return Blueprint Returns a Blueprint.
*/
public function getBlueprint(string $name = '');
/**
* Returns a form instance for the object.
*
* @param string $name Name of the form. Can be used to create customized forms for different use cases.
* @param array|null $options Options can be used to further customize the form.
* @return FlexFormInterface Returns a Form.
* @api
*/
public function getForm(string $name = '', array $options = null);
/**
* Returns default value suitable to be used in a form for the given property.
*
* @see FlexObjectInterface::getForm()
*
* @param string $name Property name.
* @param string|null $separator Optional nested property separator.
* @return mixed|null Returns default value of the field, null if there is no default value.
*/
public function getDefaultValue(string $name, string $separator = null);
/**
* Returns default values suitable to be used in a form for the given property.
*
* @see FlexObjectInterface::getForm()
*
* @return array Returns default values.
*/
public function getDefaultValues(): array;
/**
* Returns raw value suitable to be used in a form for the given property.
*
* @see FlexObjectInterface::getForm()
*
* @param string $name Property name.
* @param mixed $default Default value.
* @param string|null $separator Optional nested property separator.
* @return mixed Returns value of the field.
*/
public function getFormValue(string $name, $default = null, string $separator = null);
}

View File

@@ -0,0 +1,138 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
/**
* Defines Flex Storage layer.
*
* @since 1.6
*/
interface FlexStorageInterface
{
/**
* StorageInterface constructor.
* @param array $options
*/
public function __construct(array $options);
/**
* @return string
*/
public function getKeyField(): string;
/**
* @param string[] $keys
* @param bool $reload
* @return array
*/
public function getMetaData(array $keys, bool $reload = false): array;
/**
* Returns associated array of all existing storage keys with a timestamp.
*
* @return array Returns all existing keys as `[key => [storage_key => key, storage_timestamp => timestamp], ...]`.
*/
public function getExistingKeys(): array;
/**
* Check if the key exists in the storage.
*
* @param string $key Storage key of an object.
* @return bool Returns `true` if the key exists in the storage, `false` otherwise.
*/
public function hasKey(string $key): bool;
/**
* Check if the key exists in the storage.
*
* @param string[] $keys Storage key of an object.
* @return bool[] Returns keys with `true` if the key exists in the storage, `false` otherwise.
*/
public function hasKeys(array $keys): array;
/**
* Create new rows into the storage.
*
* New keys will be assigned when the objects are created.
*
* @param array $rows List of rows as `[row, ...]`.
* @return array Returns created rows as `[key => row, ...] pairs.
*/
public function createRows(array $rows): array;
/**
* Read rows from the storage.
*
* If you pass object or array as value, that value will be used to save I/O.
*
* @param array $rows Array of `[key => row, ...]` pairs.
* @param array|null $fetched Optional reference to store only fetched items.
* @return array Returns rows. Note that non-existing rows will have `null` as their value.
*/
public function readRows(array $rows, array &$fetched = null): array;
/**
* Update existing rows in the storage.
*
* @param array $rows Array of `[key => row, ...]` pairs.
* @return array Returns updated rows. Note that non-existing rows will not be saved and have `null` as their value.
*/
public function updateRows(array $rows): array;
/**
* Delete rows from the storage.
*
* @param array $rows Array of `[key => row, ...]` pairs.
* @return array Returns deleted rows. Note that non-existing rows have `null` as their value.
*/
public function deleteRows(array $rows): array;
/**
* Replace rows regardless if they exist or not.
*
* All rows should have a specified key for replace to work properly.
*
* @param array $rows Array of `[key => row, ...]` pairs.
* @return array Returns both created and updated rows.
*/
public function replaceRows(array $rows): array;
/**
* @param string $src
* @param string $dst
* @return bool
*/
public function copyRow(string $src, string $dst): bool;
/**
* @param string $src
* @param string $dst
* @return bool
*/
public function renameRow(string $src, string $dst): bool;
/**
* Get filesystem path for the collection or object storage.
*
* @param string|null $key Optional storage key.
* @return string|null Path in the filesystem. Can be URI or null if storage is not filesystem based.
*/
public function getStoragePath(string $key = null): ?string;
/**
* Get filesystem path for the collection or object media.
*
* @param string|null $key Optional storage key.
* @return string|null Path in the filesystem. Can be URI or null if media isn't supported.
*/
public function getMediaPath(string $key = null): ?string;
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Interfaces;
/**
* Implements PageTranslateInterface
*/
interface FlexTranslateInterface
{
/**
* Returns true if object has a translation in given language (or any of its fallback languages).
*
* @param string|null $languageCode
* @param bool|null $fallback
* @return bool
*/
public function hasTranslation(string $languageCode = null, bool $fallback = null): bool;
/**
* Get translation.
*
* @param string|null $languageCode
* @param bool|null $fallback
* @return static|null
*/
public function getTranslation(string $languageCode = null, bool $fallback = null);
/**
* Returns all translated languages.
*
* @param bool $includeDefault If set to true, return separate entries for '' and 'en' (default) language.
* @return array
*/
public function getLanguages(bool $includeDefault = false): array;
/**
* Get used language.
*
* @return string
*/
public function getLanguage(): string;
}