mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Updated a lot of docblocks
This commit is contained in:
parent
f181e1d237
commit
2777bedb51
|
|
@ -224,6 +224,7 @@ abstract class BaseAsset extends PropertyObject
|
|||
* @param string $file
|
||||
* @param string $dir
|
||||
* @param bool $local
|
||||
* @return string
|
||||
*/
|
||||
protected function cssRewrite($file, $dir, $local)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ class Pipeline extends PropertyObject
|
|||
* @param string $file the css source file
|
||||
* @param string $dir , $local relative path to the css file
|
||||
* @param bool $local is this a local or remote asset
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
protected function cssRewrite($file, $dir, $local)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class Backups
|
|||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @return array|null
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableBackups($force = false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ abstract class CompiledBase
|
|||
*
|
||||
* @param string $name Name of the position.
|
||||
* @param string|string[] $filename File(s) to be loaded.
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function loadFile($name, $filename);
|
||||
|
||||
|
|
@ -223,6 +224,7 @@ abstract class CompiledBase
|
|||
* Save compiled file.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
* @throws RuntimeException
|
||||
* @internal
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class Languages extends Data
|
|||
|
||||
/**
|
||||
* @param string|null $checksum
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function checksum($checksum = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -301,6 +301,7 @@ class Setup extends Data
|
|||
|
||||
/**
|
||||
* @param UniformResourceLocator $locator
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
* @throws BadMethodCallException
|
||||
* @throws RuntimeException
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Blueprint extends BlueprintForm
|
|||
/** @var string|null */
|
||||
protected $scope;
|
||||
|
||||
/** @var BlueprintSchema|null */
|
||||
/** @var BlueprintSchema */
|
||||
protected $blueprintSchema;
|
||||
|
||||
/** @var object|null */
|
||||
|
|
@ -60,6 +60,7 @@ class Blueprint extends BlueprintForm
|
|||
|
||||
/**
|
||||
* @param string $scope
|
||||
* @return void
|
||||
*/
|
||||
public function setScope($scope)
|
||||
{
|
||||
|
|
@ -68,6 +69,7 @@ class Blueprint extends BlueprintForm
|
|||
|
||||
/**
|
||||
* @param object $object
|
||||
* @return void
|
||||
*/
|
||||
public function setObject($object)
|
||||
{
|
||||
|
|
@ -511,7 +513,7 @@ class Blueprint extends BlueprintForm
|
|||
}
|
||||
|
||||
/**
|
||||
* @param UserInterface $user
|
||||
* @param UserInterface|null $user
|
||||
* @param array $actions
|
||||
* @param string $op
|
||||
* @return bool
|
||||
|
|
@ -562,6 +564,7 @@ class Blueprint extends BlueprintForm
|
|||
* @param array $field
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
protected function addPropertyRecursive(array &$field, $property, $value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
|
|||
*
|
||||
* @param array $data
|
||||
* @param array $options
|
||||
* @return void
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function validate(array $data, array $options = [])
|
||||
|
|
@ -197,7 +198,7 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
|
|||
* @param string $parent
|
||||
* @param bool $missingValuesAsNull
|
||||
* @param bool $keepEmptyValues
|
||||
* @return array
|
||||
* @return array|null
|
||||
*/
|
||||
protected function filterArray(array $data, array $rules, string $parent, bool $missingValuesAsNull, bool $keepEmptyValues)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
|
|||
protected $gettersVariable = 'items';
|
||||
/** @var array */
|
||||
protected $items;
|
||||
/** @var Blueprint */
|
||||
/** @var Blueprint|callable|null */
|
||||
protected $blueprints;
|
||||
/** @var FileInterface|null */
|
||||
protected $storage;
|
||||
|
|
@ -275,6 +275,8 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable
|
|||
|
||||
/**
|
||||
* Save data if storage has been defined.
|
||||
*
|
||||
* @return void
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function save()
|
||||
|
|
|
|||
|
|
@ -40,28 +40,37 @@ interface DataInterface
|
|||
|
||||
/**
|
||||
* Return blueprints.
|
||||
*
|
||||
* @return Blueprint
|
||||
*/
|
||||
public function blueprints();
|
||||
|
||||
/**
|
||||
* Validate by blueprints.
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function validate();
|
||||
|
||||
/**
|
||||
* Filter all items by using blueprints.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function filter();
|
||||
|
||||
/**
|
||||
* Get extra items which haven't been defined in blueprints.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extra();
|
||||
|
||||
/**
|
||||
* Save data into the file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save();
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ class Validation
|
|||
/**
|
||||
* @param mixed $value
|
||||
* @param array $field
|
||||
* @return array
|
||||
*/
|
||||
public static function checkSafety($value, array $field)
|
||||
{
|
||||
|
|
@ -617,7 +618,6 @@ class Validation
|
|||
* @param array $field Blueprint for the field.
|
||||
* @return bool True if validation succeeded.
|
||||
*/
|
||||
|
||||
public static function typeUrl($value, array $params, array $field)
|
||||
{
|
||||
return self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_URL);
|
||||
|
|
|
|||
|
|
@ -566,6 +566,7 @@ class Debugger
|
|||
if ($this->enabled && extension_loaded('tideways_xhprof')) {
|
||||
$this->profiling++;
|
||||
if ($this->profiling === 1) {
|
||||
// @phpstan-ignore-next-line
|
||||
\tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_NO_BUILTINS);
|
||||
}
|
||||
}
|
||||
|
|
@ -583,6 +584,7 @@ class Debugger
|
|||
if ($this->enabled && extension_loaded('tideways_xhprof')) {
|
||||
$profiling = $this->profiling - 1;
|
||||
if ($profiling === 0) {
|
||||
// @phpstan-ignore-next-line
|
||||
$timings = \tideways_xhprof_disable();
|
||||
$timings = $this->buildProfilerTimings($timings);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class SimplePageHandler extends Handler
|
|||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
public function addResourcePath($path)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ use function count;
|
|||
use function dirname;
|
||||
use function is_callable;
|
||||
|
||||
/**
|
||||
* Class Folder
|
||||
* @package Grav\Common\Filesystem
|
||||
*/
|
||||
abstract class Folder
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -690,7 +690,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withOrdered(bool $bool = true)
|
||||
{
|
||||
|
|
@ -701,7 +701,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withModules(bool $bool = true)
|
||||
{
|
||||
|
|
@ -712,7 +712,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withPages(bool $bool = true)
|
||||
{
|
||||
|
|
@ -725,7 +725,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @param bool $bool
|
||||
* @param string|null $languageCode
|
||||
* @param bool|null $fallback
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withTranslation(bool $bool = true, string $languageCode = null, bool $fallback = null)
|
||||
{
|
||||
|
|
@ -748,7 +748,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param array $filters
|
||||
* @param bool $recursive
|
||||
* @return FlexCollectionInterface
|
||||
* @return static
|
||||
*/
|
||||
public function filterBy(array $filters, bool $recursive = false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
/**
|
||||
* @param array $entries
|
||||
* @param string|null $keyField
|
||||
* @return $this|FlexPageIndex
|
||||
* @return static
|
||||
*/
|
||||
protected function createFrom(array $entries, string $keyField = null)
|
||||
{
|
||||
|
|
@ -742,11 +742,11 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param string $path
|
||||
* @param int $direction either -1 or +1
|
||||
*
|
||||
* @return PageInterface|PageCollectionInterface|false The sibling item.
|
||||
* @return PageInterface|false The sibling item.
|
||||
*/
|
||||
public function adjacentSibling($path, $direction = 1)
|
||||
{
|
||||
/** @var PageInterface|PageCollectionInterface|false $result */
|
||||
/** @var PageInterface|false $result */
|
||||
$result = $this->__call('adjacentSibling', [$path, $direction]);
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -641,6 +641,7 @@ class PageStorage extends FolderStorage
|
|||
$parentKey = '';
|
||||
}
|
||||
|
||||
/** @phpstan-var array{'storage_key': string, 'storage_timestamp': int, 'children': array<string, mixed>} $parent */
|
||||
$parent = &$list[$parentKey];
|
||||
$basename = basename($storage_key);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ trait PageTranslateTrait
|
|||
}
|
||||
|
||||
$header = $aPage->header();
|
||||
// @phpstan-ignore-next-line
|
||||
$routes = $header->routes ?? [];
|
||||
$route = $routes['default'] ?? $aPage->rawRoute();
|
||||
if (!$route) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ use Grav\Common\Flex\Traits\FlexCollectionTrait;
|
|||
use Grav\Common\Flex\Traits\FlexGravTrait;
|
||||
use Grav\Framework\Flex\FlexCollection;
|
||||
|
||||
/**
|
||||
* Class UserGroupCollection
|
||||
* @package Grav\Common\Flex\Types\UserGroups
|
||||
*/
|
||||
class UserGroupCollection extends FlexCollection
|
||||
{
|
||||
use FlexGravTrait;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ use Grav\Common\User\Interfaces\UserInterface;
|
|||
use Grav\Framework\Flex\FlexCollection;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* Class UserCollection
|
||||
* @package Grav\Common\Flex\Types\Users
|
||||
*/
|
||||
class UserCollection extends FlexCollection implements UserCollectionInterface
|
||||
{
|
||||
use FlexGravTrait;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ use function count;
|
|||
use function is_string;
|
||||
use function method_exists;
|
||||
|
||||
/**
|
||||
* Class UserIndex
|
||||
* @package Grav\Common\Flex\Types\Users
|
||||
*/
|
||||
class UserIndex extends FlexIndex
|
||||
{
|
||||
public const VERSION = parent::VERSION . '.1';
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class Grav extends Container
|
|||
public static function resetInstance()
|
||||
{
|
||||
if (self::$instance) {
|
||||
// @phpstan-ignore-next-line
|
||||
self::$instance = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use DOMDocument;
|
|||
use DOMElement;
|
||||
use Grav\Common\Page\Interfaces\PageInterface;
|
||||
use Grav\Common\Page\Markdown\Excerpts as ExcerptsObject;
|
||||
use Grav\Common\Page\Medium\Link;
|
||||
use Grav\Common\Page\Medium\Medium;
|
||||
use function is_array;
|
||||
|
||||
|
|
@ -179,7 +180,7 @@ class Excerpts
|
|||
* @param Medium $medium
|
||||
* @param string|array $url
|
||||
* @param PageInterface|null $page Page, defaults to the current page object
|
||||
* @return Medium
|
||||
* @return Medium|Link
|
||||
*/
|
||||
public static function processMediaActions($medium, $url, PageInterface $page = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class Language
|
|||
* Sets the current supported languages manually
|
||||
*
|
||||
* @param array $langs
|
||||
* @return void
|
||||
*/
|
||||
public function setLanguages($langs)
|
||||
{
|
||||
|
|
@ -188,7 +189,7 @@ class Language
|
|||
/**
|
||||
* Gets current active language
|
||||
*
|
||||
* @return string
|
||||
* @return string|false
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
|
|
@ -198,8 +199,8 @@ class Language
|
|||
/**
|
||||
* Sets active language manually
|
||||
*
|
||||
* @param string $lang
|
||||
* @return string|bool
|
||||
* @param string|false $lang
|
||||
* @return string|false
|
||||
*/
|
||||
public function setActive($lang)
|
||||
{
|
||||
|
|
@ -382,6 +383,8 @@ class Language
|
|||
* $this->grav['language']->resetFallbackPageExtensions();
|
||||
* $this->grav['pages']->init();
|
||||
* ```
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetFallbackPageExtensions()
|
||||
{
|
||||
|
|
@ -607,7 +610,7 @@ class Language
|
|||
*
|
||||
* @param string $code
|
||||
* @param string $type
|
||||
* @return bool
|
||||
* @return string|false
|
||||
*/
|
||||
public function getLanguageCode($code, $type = 'name')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Parsedown extends \Parsedown
|
|||
/**
|
||||
* Parsedown constructor.
|
||||
*
|
||||
* @param Excerpts|null $excerpts
|
||||
* @param Excerpts|PageInterface|null $excerpts
|
||||
* @param array|null $defaults
|
||||
*/
|
||||
public function __construct($excerpts = null, $defaults = null)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ParsedownExtra extends \ParsedownExtra
|
|||
/**
|
||||
* ParsedownExtra constructor.
|
||||
*
|
||||
* @param Excerpts|null $excerpts
|
||||
* @param Excerpts|PageInterface|null $excerpts
|
||||
* @param array|null $defaults
|
||||
* @throws Exception
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ trait ParsedownGravTrait
|
|||
*
|
||||
* @param PageInterface|Excerpts|null $excerpts
|
||||
* @param array|null $defaults
|
||||
* @return void
|
||||
*/
|
||||
protected function init($excerpts = null, $defaults = null)
|
||||
{
|
||||
|
|
@ -89,6 +90,7 @@ trait ParsedownGravTrait
|
|||
* @param bool $continuable
|
||||
* @param bool $completable
|
||||
* @param int|null $index
|
||||
* @return void
|
||||
*/
|
||||
public function addBlockType($type, $tag, $continuable = false, $completable = false, $index = null)
|
||||
{
|
||||
|
|
@ -120,6 +122,7 @@ trait ParsedownGravTrait
|
|||
* @param string $type
|
||||
* @param string $tag
|
||||
* @param int|null $index
|
||||
* @return void
|
||||
*/
|
||||
public function addInlineType($type, $tag, $index = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -249,12 +249,16 @@ class Pages
|
|||
|
||||
/**
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function setCheckMethod($method): void
|
||||
{
|
||||
$this->check_method = strtolower($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$config = $this->grav['config'];
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ class Uri
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
* @param string $url
|
||||
* @return array|false
|
||||
*/
|
||||
public static function parseUrl($url)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use function is_bool;
|
|||
*/
|
||||
class Access extends \Grav\Framework\Acl\Access
|
||||
{
|
||||
/** @var array[] */
|
||||
private $aliases = [
|
||||
'admin.configuration.system' => ['admin.configuration_system'],
|
||||
'admin.configuration.site' => ['admin.configuration_site', 'admin.settings'],
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ class User extends Data implements UserInterface
|
|||
|
||||
/**
|
||||
* Save user without the username
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ class Group extends Data
|
|||
|
||||
/**
|
||||
* Save a group
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ namespace Grav\Framework\Acl;
|
|||
|
||||
use Grav\Common\Utils;
|
||||
|
||||
/**
|
||||
* Class Access
|
||||
* @package Grav\Framework\Acl
|
||||
*/
|
||||
class Access implements \JsonSerializable, \IteratorAggregate, \Countable
|
||||
{
|
||||
/** @var string */
|
||||
|
|
@ -53,6 +57,7 @@ class Access implements \JsonSerializable, \IteratorAggregate, \Countable
|
|||
/**
|
||||
* @param Access $parent
|
||||
* @param string|null $name
|
||||
* @return void
|
||||
*/
|
||||
public function inherit(Access $parent, string $name = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -95,12 +95,16 @@ class Action implements \IteratorAggregate, \Countable
|
|||
|
||||
/**
|
||||
* @param Action|null $parent
|
||||
* @return void
|
||||
*/
|
||||
public function setParent(?Action $parent): void
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getScope(): string
|
||||
{
|
||||
$pos = strpos($this->name, '.');
|
||||
|
|
@ -111,6 +115,9 @@ class Action implements \IteratorAggregate, \Countable
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLevels(): int
|
||||
{
|
||||
return substr_count($this->name, '.');
|
||||
|
|
@ -143,6 +150,7 @@ class Action implements \IteratorAggregate, \Countable
|
|||
|
||||
/**
|
||||
* @param Action $child
|
||||
* @return void
|
||||
*/
|
||||
public function addChild(Action $child): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
namespace Grav\Framework\Acl;
|
||||
|
||||
/**
|
||||
* Class Permissions
|
||||
* @package Grav\Framework\Acl
|
||||
*/
|
||||
class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
{
|
||||
/** @var Action[] */
|
||||
|
|
@ -51,6 +55,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
|||
|
||||
/**
|
||||
* @param Action $action
|
||||
* @return void
|
||||
*/
|
||||
public function addAction(Action $action): void
|
||||
{
|
||||
|
|
@ -80,6 +85,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
|||
|
||||
/**
|
||||
* @param Action[] $actions
|
||||
* @return void
|
||||
*/
|
||||
public function addActions(array $actions): void
|
||||
{
|
||||
|
|
@ -107,7 +113,9 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $type
|
||||
* @return void
|
||||
*/
|
||||
public function addType(string $name, array $type): void
|
||||
{
|
||||
|
|
@ -124,6 +132,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
|||
|
||||
/**
|
||||
* @param array $types
|
||||
* @return void
|
||||
*/
|
||||
public function addTypes(array $types): void
|
||||
{
|
||||
|
|
@ -165,6 +174,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
|||
/**
|
||||
* @param int|string $offset
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
|
|
@ -173,6 +183,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
|||
|
||||
/**
|
||||
* @param int|string $offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,13 @@ namespace Grav\Framework\Acl;
|
|||
|
||||
use Grav\Common\File\CompiledYamlFile;
|
||||
|
||||
/**
|
||||
* Class PermissionsReader
|
||||
* @package Grav\Framework\Acl
|
||||
*/
|
||||
class PermissionsReader
|
||||
{
|
||||
/** @var array */
|
||||
private static $types;
|
||||
|
||||
/**
|
||||
|
|
@ -21,7 +26,6 @@ class PermissionsReader
|
|||
*/
|
||||
public static function fromYaml(string $filename): array
|
||||
{
|
||||
/** @var array $content */
|
||||
$content = CompiledYamlFile::instance($filename)->content();
|
||||
$actions = $content['actions'] ?? [];
|
||||
$types = $content['types'] ?? [];
|
||||
|
|
@ -77,6 +81,7 @@ class PermissionsReader
|
|||
|
||||
/**
|
||||
* @param array $types
|
||||
* @return void
|
||||
*/
|
||||
protected static function initTypes(array $types)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ class ChainCache extends AbstractCache
|
|||
while ($i--) {
|
||||
$success = $this->caches[$i]->doClear() && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ class ChainCache extends AbstractCache
|
|||
$values = [];
|
||||
/**
|
||||
* @var int $i
|
||||
* @var CacheInterface $cache
|
||||
* @var CacheInterface $items
|
||||
*/
|
||||
foreach (array_reverse($list) as $i => $items) {
|
||||
$values += $items;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ class DoctrineCache extends AbstractCache
|
|||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
*/
|
||||
public function doDeleteMultiple($keys)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,11 @@ class FileCache extends AbstractCache
|
|||
private $tmp;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* FileCache constructor.
|
||||
* @param string $namespace
|
||||
* @param int|null $defaultLifetime
|
||||
* @param string|null $folder
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($namespace = '', $defaultLifetime = null, $folder = null)
|
||||
{
|
||||
|
|
@ -67,7 +71,7 @@ class FileCache extends AbstractCache
|
|||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\CacheException|InvalidArgumentException
|
||||
* @throws CacheException
|
||||
*/
|
||||
public function doSet($key, $value, $ttl)
|
||||
{
|
||||
|
|
@ -141,7 +145,8 @@ class FileCache extends AbstractCache
|
|||
/**
|
||||
* @param string $namespace
|
||||
* @param string $directory
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function initFileCache($namespace, $directory)
|
||||
{
|
||||
|
|
@ -197,6 +202,7 @@ class FileCache extends AbstractCache
|
|||
|
||||
/**
|
||||
* @param string $dir
|
||||
* @return void
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
private function mkdir($dir)
|
||||
|
|
@ -218,6 +224,11 @@ class FileCache extends AbstractCache
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
* @param string $message
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
* @return bool
|
||||
* @internal
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ class MemoryCache extends AbstractCache
|
|||
/** @var array */
|
||||
protected $cache = [];
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $miss
|
||||
* @return mixed
|
||||
*/
|
||||
public function doGet($key, $miss)
|
||||
{
|
||||
if (!array_key_exists($key, $this->cache)) {
|
||||
|
|
@ -32,6 +37,12 @@ class MemoryCache extends AbstractCache
|
|||
return $this->cache[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function doSet($key, $value, $ttl)
|
||||
{
|
||||
$this->cache[$key] = $value;
|
||||
|
|
@ -39,6 +50,10 @@ class MemoryCache extends AbstractCache
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function doDelete($key)
|
||||
{
|
||||
unset($this->cache[$key]);
|
||||
|
|
@ -46,6 +61,9 @@ class MemoryCache extends AbstractCache
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function doClear()
|
||||
{
|
||||
$this->cache = [];
|
||||
|
|
@ -53,6 +71,10 @@ class MemoryCache extends AbstractCache
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function doHas($key)
|
||||
{
|
||||
return array_key_exists($key, $this->cache);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ class SessionCache extends AbstractCache
|
|||
public const VALUE = 0;
|
||||
public const LIFETIME = 1;
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $miss
|
||||
* @return mixed
|
||||
*/
|
||||
public function doGet($key, $miss)
|
||||
{
|
||||
$stored = $this->doGetStored($key);
|
||||
|
|
@ -28,6 +33,12 @@ class SessionCache extends AbstractCache
|
|||
return $stored ? $stored[self::VALUE] : $miss;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function doSet($key, $value, $ttl)
|
||||
{
|
||||
$stored = [self::VALUE => $value];
|
||||
|
|
@ -40,6 +51,10 @@ class SessionCache extends AbstractCache
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function doDelete($key)
|
||||
{
|
||||
unset($_SESSION[$this->getNamespace()][$key]);
|
||||
|
|
@ -47,6 +62,9 @@ class SessionCache extends AbstractCache
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function doClear()
|
||||
{
|
||||
unset($_SESSION[$this->getNamespace()]);
|
||||
|
|
@ -54,16 +72,27 @@ class SessionCache extends AbstractCache
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function doHas($key)
|
||||
{
|
||||
return $this->doGetStored($key) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return 'cache-' . parent::getNamespace();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return mixed|null
|
||||
*/
|
||||
protected function doGetStored($key)
|
||||
{
|
||||
$stored = $_SESSION[$this->getNamespace()][$key] ?? null;
|
||||
|
|
|
|||
|
|
@ -17,12 +17,55 @@ use Psr\SimpleCache\CacheInterface as SimpleCacheInterface;
|
|||
*/
|
||||
interface CacheInterface extends SimpleCacheInterface
|
||||
{
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $miss
|
||||
* @return mixed
|
||||
*/
|
||||
public function doGet($key, $miss);
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int|null $ttl
|
||||
* @return mixed
|
||||
*/
|
||||
public function doSet($key, $value, $ttl);
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function doDelete($key);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function doClear();
|
||||
|
||||
/**
|
||||
* @param string[] $keys
|
||||
* @param mixed $miss
|
||||
* @return mixed
|
||||
*/
|
||||
public function doGetMultiple($keys, $miss);
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $values
|
||||
* @param int|null $ttl
|
||||
* @return mixed
|
||||
*/
|
||||
public function doSetMultiple($values, $ttl);
|
||||
|
||||
/**
|
||||
* @param string[] $keys
|
||||
* @return mixed
|
||||
*/
|
||||
public function doDeleteMultiple($keys);
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function doHas($key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,10 @@ trait CacheTrait
|
|||
{
|
||||
/** @var string */
|
||||
private $namespace = '';
|
||||
|
||||
/** @var int|null */
|
||||
private $defaultLifetime = null;
|
||||
|
||||
/** @var \stdClass */
|
||||
private $miss;
|
||||
|
||||
/** @var bool */
|
||||
private $validation = true;
|
||||
|
||||
|
|
@ -34,7 +31,8 @@ trait CacheTrait
|
|||
*
|
||||
* @param string $namespace
|
||||
* @param null|int|\DateInterval $defaultLifetime
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function init($namespace = '', $defaultLifetime = null)
|
||||
{
|
||||
|
|
@ -45,6 +43,7 @@ trait CacheTrait
|
|||
|
||||
/**
|
||||
* @param bool $validation
|
||||
* @return void
|
||||
*/
|
||||
public function setValidation($validation)
|
||||
{
|
||||
|
|
@ -68,8 +67,10 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param string $key
|
||||
* @param mixed|null $default
|
||||
* @return mixed|null
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
|
|
@ -81,8 +82,11 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param null|int|\DateInterval $ttl
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
|
|
@ -95,8 +99,9 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param string $key
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
|
|
@ -106,7 +111,7 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
|
|
@ -114,8 +119,10 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param iterable $keys
|
||||
* @param mixed|null $default
|
||||
* @return iterable
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
{
|
||||
|
|
@ -158,8 +165,10 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param iterable $values
|
||||
* @param null|int|\DateInterval $ttl
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
|
|
@ -190,8 +199,9 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param iterable $keys
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
{
|
||||
|
|
@ -217,8 +227,9 @@ trait CacheTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @param string $key
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
|
|
@ -227,11 +238,6 @@ trait CacheTrait
|
|||
return $this->doHas($key);
|
||||
}
|
||||
|
||||
abstract public function doGet($key, $miss);
|
||||
abstract public function doSet($key, $value, $ttl);
|
||||
abstract public function doDelete($key);
|
||||
abstract public function doClear();
|
||||
|
||||
/**
|
||||
* @param array $keys
|
||||
* @param mixed $miss
|
||||
|
|
@ -282,11 +288,10 @@ trait CacheTrait
|
|||
return $success;
|
||||
}
|
||||
|
||||
abstract public function doHas($key);
|
||||
|
||||
/**
|
||||
* @param string|mixed $key
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function validateKey($key)
|
||||
{
|
||||
|
|
@ -315,7 +320,8 @@ trait CacheTrait
|
|||
|
||||
/**
|
||||
* @param array $keys
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function validateKeys($keys)
|
||||
{
|
||||
|
|
@ -331,7 +337,7 @@ trait CacheTrait
|
|||
/**
|
||||
* @param null|int|\DateInterval $ttl
|
||||
* @return int|null
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function convertTtl($ttl)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,19 +24,14 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
|
|||
{
|
||||
/** @var string */
|
||||
protected $path;
|
||||
|
||||
/** @var \RecursiveDirectoryIterator|RecursiveUniformResourceIterator */
|
||||
protected $iterator;
|
||||
|
||||
/** @var callable */
|
||||
protected $createObjectFunction;
|
||||
|
||||
/** @var callable|null */
|
||||
protected $filterFunction;
|
||||
|
||||
/** @var int */
|
||||
protected $flags;
|
||||
|
||||
/** @var int */
|
||||
protected $nestingLimit;
|
||||
|
||||
|
|
@ -108,6 +103,9 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
|
|||
return new ArrayCollection($filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function setIterator()
|
||||
{
|
||||
$iteratorFlags = \RecursiveDirectoryIterator::SKIP_DOTS + \FilesystemIterator::UNIX_PATHS
|
||||
|
|
@ -151,6 +149,11 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
|
|||
$this->collection = new ArrayCollection($filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SeekableIterator $iterator
|
||||
* @param int $nestingLimit
|
||||
* @return array
|
||||
*/
|
||||
protected function doInitializeByIterator(\SeekableIterator $iterator, $nestingLimit)
|
||||
{
|
||||
$children = [];
|
||||
|
|
@ -193,6 +196,7 @@ class AbstractFileCollection extends AbstractLazyCollection implements FileColle
|
|||
|
||||
/**
|
||||
* @param array $children
|
||||
* @param int $nestingLimit
|
||||
* @return array
|
||||
*/
|
||||
protected function doInitializeChildren(array $children, $nestingLimit)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
|
|||
*/
|
||||
abstract class AbstractIndexCollection implements CollectionInterface
|
||||
{
|
||||
/** @var array */
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $entries;
|
||||
|
||||
/**
|
||||
|
|
@ -416,6 +418,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function serialize()
|
||||
|
|
@ -425,6 +428,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
|
||||
/**
|
||||
* @param string $serialized
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
|
|
@ -450,7 +454,6 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
* instance should be created when constructor semantics have changed.
|
||||
*
|
||||
* @param array $entries Elements.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
protected function createFrom(array $entries)
|
||||
|
|
@ -468,6 +471,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
|
||||
/**
|
||||
* @param array $entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setEntries(array $entries): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
|
|||
*
|
||||
* Collection is returned in the order of $keys given to the function.
|
||||
*
|
||||
* @param array $keys
|
||||
* @param array<int|string> $keys
|
||||
* @return static
|
||||
*/
|
||||
public function select(array $keys)
|
||||
|
|
@ -75,7 +75,7 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
|
|||
/**
|
||||
* Un-select items from collection.
|
||||
*
|
||||
* @param array $keys
|
||||
* @param array<int|string> $keys
|
||||
* @return static
|
||||
*/
|
||||
public function unselect(array $keys)
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ interface CollectionInterface extends Collection, \JsonSerializable
|
|||
/**
|
||||
* Reverse the order of the items.
|
||||
*
|
||||
* @return static|CollectionInterface
|
||||
* @return CollectionInterface
|
||||
*/
|
||||
public function reverse();
|
||||
|
||||
/**
|
||||
* Shuffle items.
|
||||
*
|
||||
* @return static|CollectionInterface
|
||||
* @return CollectionInterface
|
||||
*/
|
||||
public function shuffle();
|
||||
|
||||
|
|
@ -45,16 +45,16 @@ interface CollectionInterface extends Collection, \JsonSerializable
|
|||
*
|
||||
* Collection is returned in the order of $keys given to the function.
|
||||
*
|
||||
* @param array $keys
|
||||
* @return static|CollectionInterface
|
||||
* @param array<int|string> $keys
|
||||
* @return CollectionInterface
|
||||
*/
|
||||
public function select(array $keys);
|
||||
|
||||
/**
|
||||
* Un-select items from collection.
|
||||
*
|
||||
* @param array $keys
|
||||
* @return static|CollectionInterface
|
||||
* @param array<int|string> $keys
|
||||
* @return CollectionInterface
|
||||
*/
|
||||
public function unselect(array $keys);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ContentBlock implements ContentBlockInterface
|
|||
protected $cached = true;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string|null $id
|
||||
* @return static
|
||||
*/
|
||||
public static function create($id = null)
|
||||
|
|
@ -75,7 +75,7 @@ class ContentBlock implements ContentBlockInterface
|
|||
/**
|
||||
* Block constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string|null $id
|
||||
*/
|
||||
public function __construct($id = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Grav\Framework\ContentBlock;
|
|||
interface ContentBlockInterface extends \Serializable
|
||||
{
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string|null $id
|
||||
* @return static
|
||||
*/
|
||||
public static function create($id = null);
|
||||
|
|
@ -28,7 +28,7 @@ interface ContentBlockInterface extends \Serializable
|
|||
public static function fromArray(array $serialized);
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string|null $id
|
||||
*/
|
||||
public function __construct($id = null);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ use Grav\Framework\Route\Route;
|
|||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Trait ControllerResponseTrait
|
||||
* @package Grav\Framework\Controller\Traits
|
||||
*/
|
||||
trait ControllerResponseTrait
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,11 +15,19 @@ use Psr\Container\ContainerInterface;
|
|||
|
||||
class Container extends \Pimple\Container implements ContainerInterface
|
||||
{
|
||||
/**
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
return $this->offsetGet($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function has($id): bool
|
||||
{
|
||||
return $this->offsetExists($id);
|
||||
|
|
|
|||
|
|
@ -14,29 +14,26 @@ namespace Grav\Framework\File;
|
|||
use Grav\Framework\File\Interfaces\FileInterface;
|
||||
use Grav\Framework\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* Class AbstractFile
|
||||
* @package Grav\Framework\File
|
||||
*/
|
||||
class AbstractFile implements FileInterface
|
||||
{
|
||||
/** @var Filesystem */
|
||||
private $filesystem;
|
||||
|
||||
/** @var string */
|
||||
private $filepath;
|
||||
|
||||
/** @var string|null */
|
||||
private $filename;
|
||||
|
||||
/** @var string|null */
|
||||
private $path;
|
||||
|
||||
/** @var string|null */
|
||||
private $basename;
|
||||
|
||||
/** @var string|null */
|
||||
private $extension;
|
||||
|
||||
/** @var resource|null */
|
||||
private $handle;
|
||||
|
||||
/** @var bool */
|
||||
private $locked = false;
|
||||
|
||||
|
|
@ -60,6 +57,9 @@ class AbstractFile implements FileInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->handle = null;
|
||||
|
|
@ -76,6 +76,7 @@ class AbstractFile implements FileInterface
|
|||
|
||||
/**
|
||||
* @param string $serialized
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized): void
|
||||
{
|
||||
|
|
@ -368,6 +369,7 @@ class AbstractFile implements FileInterface
|
|||
|
||||
/**
|
||||
* @param array $serialized
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnserialize(array $serialized): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ namespace Grav\Framework\File;
|
|||
use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class DataFile
|
||||
* @package Grav\Framework\File
|
||||
*/
|
||||
class DataFile extends AbstractFile
|
||||
{
|
||||
/** @var FileFormatterInterface */
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Grav\Framework\File;
|
||||
|
||||
/**
|
||||
* Class File
|
||||
* @package Grav\Framework\File
|
||||
*/
|
||||
class File extends AbstractFile
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ abstract class AbstractFormatter implements FileFormatterInterface
|
|||
* Note: if overridden, make sure you call parent::doUnserialize()
|
||||
*
|
||||
* @param array $serialized
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnserialize(array $serialized): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\File\Formatter;
|
|||
|
||||
use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
||||
|
||||
/**
|
||||
* Class CsvFormatter
|
||||
* @package Grav\Framework\File\Formatter
|
||||
*/
|
||||
class CsvFormatter extends AbstractFormatter
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
|||
*/
|
||||
interface FormatterInterface extends FileFormatterInterface
|
||||
{
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\File\Formatter;
|
|||
|
||||
use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
||||
|
||||
/**
|
||||
* Class IniFormatter
|
||||
* @package Grav\Framework\File\Formatter
|
||||
*/
|
||||
class IniFormatter extends AbstractFormatter
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,8 +15,13 @@ use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
|||
use function is_int;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* Class JsonFormatter
|
||||
* @package Grav\Framework\File\Formatter
|
||||
*/
|
||||
class JsonFormatter extends AbstractFormatter
|
||||
{
|
||||
/** @var array */
|
||||
protected $encodeOptions = [
|
||||
'JSON_FORCE_OBJECT' => JSON_FORCE_OBJECT,
|
||||
'JSON_HEX_QUOT' => JSON_HEX_QUOT,
|
||||
|
|
@ -35,6 +40,7 @@ class JsonFormatter extends AbstractFormatter
|
|||
//'JSON_THROW_ON_ERROR' => JSON_THROW_ON_ERROR // PHP 7.3
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
protected $decodeOptions = [
|
||||
'JSON_BIGINT_AS_STRING' => JSON_BIGINT_AS_STRING,
|
||||
'JSON_INVALID_UTF8_IGNORE' => JSON_INVALID_UTF8_IGNORE,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\File\Formatter;
|
|||
|
||||
use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
||||
|
||||
/**
|
||||
* Class MarkdownFormatter
|
||||
* @package Grav\Framework\File\Formatter
|
||||
*/
|
||||
class MarkdownFormatter extends AbstractFormatter
|
||||
{
|
||||
/** @var FileFormatterInterface */
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\File\Formatter;
|
|||
|
||||
use Grav\Framework\File\Interfaces\FileFormatterInterface;
|
||||
|
||||
/**
|
||||
* Class SerializeFormatter
|
||||
* @package Grav\Framework\File\Formatter
|
||||
*/
|
||||
class SerializeFormatter extends AbstractFormatter
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,8 +17,16 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
|||
use Symfony\Component\Yaml\Yaml as YamlParser;
|
||||
use RocketTheme\Toolbox\Compat\Yaml\Yaml as FallbackYamlParser;
|
||||
|
||||
/**
|
||||
* Class YamlFormatter
|
||||
* @package Grav\Framework\File\Formatter
|
||||
*/
|
||||
class YamlFormatter extends AbstractFormatter
|
||||
{
|
||||
/**
|
||||
* YamlFormatter constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
$config += [
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ interface FileFormatterInterface extends \Serializable
|
|||
* Encode data into a string.
|
||||
*
|
||||
* @param mixed $data Data to be encoded.
|
||||
*
|
||||
* @return string Returns encoded data as a string.
|
||||
* @api
|
||||
*/
|
||||
|
|
@ -64,7 +63,6 @@ interface FileFormatterInterface extends \Serializable
|
|||
* Decode a string into data.
|
||||
*
|
||||
* @param string $data String to be decoded.
|
||||
*
|
||||
* @return mixed Returns decoded data.
|
||||
* @api
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\Filesystem;
|
|||
|
||||
use Grav\Framework\Filesystem\Interfaces\FilesystemInterface;
|
||||
|
||||
/**
|
||||
* Class Filesystem
|
||||
* @package Grav\Framework\Filesystem
|
||||
*/
|
||||
class Filesystem implements FilesystemInterface
|
||||
{
|
||||
/** @var bool|null */
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ use function count;
|
|||
use function get_class;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Class FlexIndex
|
||||
* @package Grav\Framework\Flex
|
||||
*/
|
||||
class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexIndexInterface
|
||||
{
|
||||
const VERSION = 1;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class FlexPageCollection extends FlexCollection
|
|||
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withPublished(bool $bool = true)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ class FlexPageCollection extends FlexCollection
|
|||
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withVisible(bool $bool = true)
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ class FlexPageCollection extends FlexCollection
|
|||
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return FlexCollectionInterface|FlexPageCollection
|
||||
* @return static
|
||||
*/
|
||||
public function withRoutable(bool $bool = true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface
|
|||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return File
|
||||
* @return CompiledJsonFile|CompiledYamlFile|CompiledMarkdownFile
|
||||
*/
|
||||
protected function getFile(string $filename)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ use Psr\Http\Message\UploadedFileInterface;
|
|||
use RocketTheme\Toolbox\File\YamlFile;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
|
||||
/**
|
||||
* Class FormFlash
|
||||
* @package Grav\Framework\Form
|
||||
*/
|
||||
class FormFlash implements FormFlashInterface
|
||||
{
|
||||
/** @var bool */
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ use Grav\Framework\Psr7\Stream;
|
|||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* Class FormFlashFile
|
||||
* @package Grav\Framework\Form
|
||||
*/
|
||||
class FormFlashFile implements UploadedFileInterface, \JsonSerializable
|
||||
{
|
||||
/** @var string */
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ namespace Grav\Framework\Form\Interfaces;
|
|||
use Grav\Common\Page\Interfaces\PageInterface;
|
||||
use Grav\Common\Page\Page;
|
||||
|
||||
/**
|
||||
* Interface FormFactoryInterface
|
||||
* @package Grav\Framework\Form\Interfaces
|
||||
*/
|
||||
interface FormFactoryInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ namespace Grav\Framework\Form\Interfaces;
|
|||
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* Interface FormFlashInterface
|
||||
* @package Grav\Framework\Form\Interfaces
|
||||
*/
|
||||
interface FormFlashInterface extends \JsonSerializable
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -684,15 +684,6 @@ trait FormTrait
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submit logic goes here.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $files
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function doSubmit(array $data, array $files);
|
||||
|
||||
/**
|
||||
* Validate data and throw validation exceptions if validation fails.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ trait ArrayAccessTrait
|
|||
*
|
||||
* @param mixed $offset The offset to assign the value to.
|
||||
* @param mixed $value The value to set.
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
|
|
@ -52,14 +53,10 @@ trait ArrayAccessTrait
|
|||
* Unsets an offset.
|
||||
*
|
||||
* @param mixed $offset The offset to unset.
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->unsetProperty($offset);
|
||||
}
|
||||
|
||||
abstract public function hasProperty($property);
|
||||
abstract public function getProperty($property, $default = null);
|
||||
abstract public function setProperty($property, $value);
|
||||
abstract public function unsetProperty($property);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ trait NestedArrayAccessTrait
|
|||
*
|
||||
* @param mixed $offset The offset to assign the value to.
|
||||
* @param mixed $value The value to set.
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
|
|
@ -52,14 +53,10 @@ trait NestedArrayAccessTrait
|
|||
* Unsets an offset.
|
||||
*
|
||||
* @param mixed $offset The offset to unset.
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->unsetNestedProperty($offset);
|
||||
}
|
||||
|
||||
abstract public function hasNestedProperty($property, $separator = null);
|
||||
abstract public function getNestedProperty($property, $default = null, $separator = null);
|
||||
abstract public function setNestedProperty($property, $value, $separator = null);
|
||||
abstract public function unsetNestedProperty($property, $separator = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ trait NestedPropertyCollectionTrait
|
|||
{
|
||||
/**
|
||||
* @param string $property Object property to be matched.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return array Key/Value pairs of the properties.
|
||||
*/
|
||||
public function hasNestedProperty($property, $separator = null)
|
||||
|
|
@ -37,7 +37,7 @@ trait NestedPropertyCollectionTrait
|
|||
/**
|
||||
* @param string $property Object property to be fetched.
|
||||
* @param mixed $default Default value if not set.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return array Key/Value pairs of the properties.
|
||||
*/
|
||||
public function getNestedProperty($property, $default = null, $separator = null)
|
||||
|
|
@ -55,7 +55,7 @@ trait NestedPropertyCollectionTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
*/
|
||||
public function setNestedProperty($property, $value, $separator = null)
|
||||
|
|
@ -70,7 +70,7 @@ trait NestedPropertyCollectionTrait
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
*/
|
||||
public function unsetNestedProperty($property, $separator = null)
|
||||
|
|
@ -86,7 +86,7 @@ trait NestedPropertyCollectionTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param string $default Default value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
*/
|
||||
public function defNestedProperty($property, $default, $separator = null)
|
||||
|
|
@ -103,7 +103,7 @@ trait NestedPropertyCollectionTrait
|
|||
* Group items in the collection by a field.
|
||||
*
|
||||
* @param string $property Object property to be used to make groups.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return array
|
||||
*/
|
||||
public function group($property, $separator = null)
|
||||
|
|
@ -117,9 +117,4 @@ trait NestedPropertyCollectionTrait
|
|||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable
|
||||
*/
|
||||
abstract public function getIterator();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ trait NestedPropertyTrait
|
|||
{
|
||||
/**
|
||||
* @param string $property Object property name.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return bool True if property has been defined (can be null).
|
||||
*/
|
||||
public function hasNestedProperty($property, $separator = null)
|
||||
|
|
@ -74,7 +74,7 @@ trait NestedPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
|
|
@ -116,7 +116,7 @@ trait NestedPropertyTrait
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
|
|
@ -161,7 +161,7 @@ trait NestedPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $default Default value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return $this
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
|
|
@ -173,11 +173,4 @@ trait NestedPropertyTrait
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
abstract public function hasProperty($property);
|
||||
abstract public function getProperty($property, $default = null);
|
||||
abstract public function setProperty($property, $value);
|
||||
abstract public function unsetProperty($property);
|
||||
abstract protected function &doGetProperty($property, $default = null, $doCreate = false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ trait OverloadedPropertyTrait
|
|||
*
|
||||
* @param mixed $offset The offset to assign the value to.
|
||||
* @param mixed $value The value to set.
|
||||
* @return void
|
||||
*/
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
|
|
@ -52,14 +53,10 @@ trait OverloadedPropertyTrait
|
|||
* Magic method to unset the attribute
|
||||
*
|
||||
* @param mixed $offset The name value to unset
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($offset)
|
||||
{
|
||||
$this->unsetProperty($offset);
|
||||
}
|
||||
|
||||
abstract public function hasProperty($property);
|
||||
abstract public function getProperty($property, $default = null);
|
||||
abstract public function setProperty($property, $value);
|
||||
abstract public function unsetProperty($property);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ trait ObjectCollectionTrait
|
|||
|
||||
/**
|
||||
* @param string $serialized
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
|
|
@ -152,6 +153,7 @@ trait ObjectCollectionTrait
|
|||
|
||||
/**
|
||||
* @param array $serialized
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnserialize(array $serialized)
|
||||
{
|
||||
|
|
@ -210,7 +212,7 @@ trait ObjectCollectionTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getObjectKeys()
|
||||
{
|
||||
|
|
@ -344,6 +346,7 @@ trait ObjectCollectionTrait
|
|||
{
|
||||
$collections = [];
|
||||
foreach ($this->group($property) as $id => $elements) {
|
||||
/** @var static $collection */
|
||||
$collection = $this->createFrom($elements);
|
||||
|
||||
$collections[$id] = $collection;
|
||||
|
|
@ -351,12 +354,4 @@ trait ObjectCollectionTrait
|
|||
|
||||
return $collections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable
|
||||
*/
|
||||
abstract public function getIterator();
|
||||
|
||||
abstract protected function getElements();
|
||||
abstract protected function setElements(array $elements);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ trait ObjectTrait
|
|||
|
||||
/**
|
||||
* @param array $serialized
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnserialize(array $serialized)
|
||||
{
|
||||
|
|
@ -192,11 +193,4 @@ trait ObjectTrait
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
abstract protected function doHasProperty($property);
|
||||
abstract protected function &doGetProperty($property, $default = null, $doCreate = false);
|
||||
abstract protected function doSetProperty($property, $value);
|
||||
abstract protected function doUnsetProperty($property);
|
||||
abstract protected function getElements();
|
||||
abstract protected function setElements(array $elements);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
|
|||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
use function is_callable;
|
||||
|
||||
/**
|
||||
* Class ObjectExpressionVisitor
|
||||
* @package Grav\Framework\Object\Collection
|
||||
*/
|
||||
class ObjectExpressionVisitor extends ClosureExpressionVisitor
|
||||
{
|
||||
/**
|
||||
|
|
@ -222,7 +226,6 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor
|
|||
return $value === substr(static::getObjectFieldValue($object, $field), -strlen($value));
|
||||
};
|
||||
|
||||
|
||||
default:
|
||||
throw new \RuntimeException("Unknown comparison operator: " . $comparison->getOperator());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
|
|||
|
||||
/**
|
||||
* @param array $elements
|
||||
* @param string $key
|
||||
* @param string|null $key
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $elements = [], $key = null)
|
||||
|
|
@ -41,7 +41,7 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
|
|||
|
||||
/**
|
||||
* @param array $ordering
|
||||
* @return Collection|static
|
||||
* @return static
|
||||
*/
|
||||
public function orderBy(array $ordering)
|
||||
{
|
||||
|
|
@ -61,7 +61,8 @@ class ObjectCollection extends ArrayCollection implements NestedObjectCollection
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @param Criteria $criteria
|
||||
* @return static
|
||||
*/
|
||||
public function matching(Criteria $criteria)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
|
|||
|
||||
/**
|
||||
* @param string $property Object property name.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return bool[] True if property has been defined (can be null).
|
||||
*/
|
||||
public function hasNestedProperty($property, $separator = null)
|
||||
|
|
@ -125,7 +125,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
|
|||
/**
|
||||
* @param string $property Object property to be fetched.
|
||||
* @param mixed $default Default value if property has not been set.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return mixed[] Property values.
|
||||
*/
|
||||
public function getNestedProperty($property, $default = null, $separator = null)
|
||||
|
|
@ -136,7 +136,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return ObjectCollectionInterface
|
||||
*/
|
||||
public function setNestedProperty($property, $value, $separator = null)
|
||||
|
|
@ -147,7 +147,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
|
|||
/**
|
||||
* @param string $property Object property to be defined.
|
||||
* @param mixed $default Default value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return ObjectCollectionInterface
|
||||
*/
|
||||
public function defNestedProperty($property, $default, $separator = null)
|
||||
|
|
@ -157,7 +157,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be unset.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
* @param string|null $separator Separator, defaults to '.'
|
||||
* @return ObjectCollectionInterface
|
||||
*/
|
||||
public function unsetNestedProperty($property, $separator = null)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ trait ArrayPropertyTrait
|
|||
|
||||
/**
|
||||
* @param array $elements
|
||||
* @param string $key
|
||||
* @param string|null $key
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $elements = [], $key = null)
|
||||
|
|
@ -63,6 +63,7 @@ trait ArrayPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @return void
|
||||
*/
|
||||
protected function doSetProperty($property, $value)
|
||||
{
|
||||
|
|
@ -71,6 +72,7 @@ trait ArrayPropertyTrait
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be unset.
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnsetProperty($property)
|
||||
{
|
||||
|
|
@ -99,6 +101,7 @@ trait ArrayPropertyTrait
|
|||
|
||||
/**
|
||||
* @param array $elements
|
||||
* @return void
|
||||
*/
|
||||
protected function setElements(array $elements)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ trait LazyPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be fetched.
|
||||
* @param mixed $default Default value if property has not been set.
|
||||
* @param bool $doCreate
|
||||
* @return mixed Property value.
|
||||
*/
|
||||
protected function &doGetProperty($property, $default = null, $doCreate = false)
|
||||
|
|
@ -69,6 +70,7 @@ trait LazyPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @return void
|
||||
*/
|
||||
protected function doSetProperty($property, $value)
|
||||
{
|
||||
|
|
@ -81,6 +83,7 @@ trait LazyPropertyTrait
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be unset.
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnsetProperty($property)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ trait MixedPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be fetched.
|
||||
* @param mixed $default Default value if property has not been set.
|
||||
* @param bool $doCreate
|
||||
* @return mixed Property value.
|
||||
*/
|
||||
protected function &doGetProperty($property, $default = null, $doCreate = false)
|
||||
|
|
@ -68,6 +69,7 @@ trait MixedPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @return void
|
||||
*/
|
||||
protected function doSetProperty($property, $value)
|
||||
{
|
||||
|
|
@ -77,6 +79,7 @@ trait MixedPropertyTrait
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be unset.
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnsetProperty($property)
|
||||
{
|
||||
|
|
@ -108,6 +111,7 @@ trait MixedPropertyTrait
|
|||
|
||||
/**
|
||||
* @param array $elements
|
||||
* @return void
|
||||
*/
|
||||
protected function setElements(array $elements)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ trait ObjectPropertyTrait
|
|||
/**
|
||||
* @param string $property Object property to be updated.
|
||||
* @param mixed $value New value.
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function doSetProperty($property, $value)
|
||||
|
|
@ -137,6 +138,7 @@ trait ObjectPropertyTrait
|
|||
|
||||
/**
|
||||
* @param string $property Object property to be unset.
|
||||
* @return void
|
||||
*/
|
||||
protected function doUnsetProperty($property)
|
||||
{
|
||||
|
|
@ -148,6 +150,9 @@ trait ObjectPropertyTrait
|
|||
$this->{$property} = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function initObjectProperties()
|
||||
{
|
||||
$this->_definedProperties = [];
|
||||
|
|
@ -192,6 +197,7 @@ trait ObjectPropertyTrait
|
|||
|
||||
/**
|
||||
* @param array $elements
|
||||
* @return void
|
||||
*/
|
||||
protected function setElements(array $elements)
|
||||
{
|
||||
|
|
@ -199,7 +205,4 @@ trait ObjectPropertyTrait
|
|||
$this->setProperty($property, $value);
|
||||
}
|
||||
}
|
||||
|
||||
abstract public function setProperty($property, $value);
|
||||
abstract protected function setKey($key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,38 +12,32 @@ namespace Grav\Framework\Pagination;
|
|||
use Grav\Framework\Pagination\Interfaces\PaginationInterface;
|
||||
use Grav\Framework\Route\Route;
|
||||
|
||||
/**
|
||||
* Class AbstractPagination
|
||||
* @package Grav\Framework\Pagination
|
||||
*/
|
||||
class AbstractPagination implements PaginationInterface
|
||||
{
|
||||
/** @var Route Base rouse used for the pagination. */
|
||||
protected $route;
|
||||
|
||||
/** @var int|null Current page. */
|
||||
protected $page;
|
||||
|
||||
/** @var int|null The record number to start displaying from. */
|
||||
protected $start;
|
||||
|
||||
/** @var int Number of records to display per page. */
|
||||
protected $limit;
|
||||
|
||||
/** @var int Total number of records. */
|
||||
protected $total;
|
||||
|
||||
/** @var array Pagination options */
|
||||
protected $options;
|
||||
|
||||
/** @var bool View all flag. */
|
||||
protected $viewAll;
|
||||
|
||||
/** @var int Total number of pages. */
|
||||
protected $pages;
|
||||
|
||||
/** @var int Value pagination object begins at. */
|
||||
protected $pagesStart;
|
||||
|
||||
/** @var int Value pagination object ends at .*/
|
||||
protected $pagesStop;
|
||||
|
||||
/** @var array */
|
||||
protected $defaultOptions = [
|
||||
'type' => 'page',
|
||||
|
|
@ -53,7 +47,6 @@ class AbstractPagination implements PaginationInterface
|
|||
'ending' => 0,
|
||||
'url' => null
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
private $items;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,41 +11,66 @@ namespace Grav\Framework\Pagination;
|
|||
|
||||
use Grav\Framework\Pagination\Interfaces\PaginationPageInterface;
|
||||
|
||||
/**
|
||||
* Class AbstractPaginationPage
|
||||
* @package Grav\Framework\Pagination
|
||||
*/
|
||||
abstract class AbstractPaginationPage implements PaginationPageInterface
|
||||
{
|
||||
/** @var array */
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->options['active'] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->options['enabled'] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->options ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getNumber(): ?int
|
||||
{
|
||||
return $this->options['number'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->options['label'] ?? (string)$this->getNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->options['route'] ? (string)$this->options['route']->getUri() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
protected function setOptions(array $options): void
|
||||
{
|
||||
$this->options = $options;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,20 @@ namespace Grav\Framework\Pagination;
|
|||
|
||||
use Grav\Framework\Route\Route;
|
||||
|
||||
/**
|
||||
* Class Pagination
|
||||
* @package Grav\Framework\Pagination
|
||||
*/
|
||||
class Pagination extends AbstractPagination
|
||||
{
|
||||
/**
|
||||
* Pagination constructor.
|
||||
* @param Route $route
|
||||
* @param int $total
|
||||
* @param int|null $pos
|
||||
* @param int|null $limit
|
||||
* @param array|null $options
|
||||
*/
|
||||
public function __construct(Route $route, int $total, int $pos = null, int $limit = null, array $options = null)
|
||||
{
|
||||
$this->initialize($route, $total, $pos, $limit, $options);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,16 @@
|
|||
|
||||
namespace Grav\Framework\Pagination;
|
||||
|
||||
/**
|
||||
* Class PaginationPage
|
||||
* @package Grav\Framework\Pagination
|
||||
*/
|
||||
class PaginationPage extends AbstractPaginationPage
|
||||
{
|
||||
/**
|
||||
* PaginationPage constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->setOptions($options);
|
||||
|
|
|
|||
|
|
@ -28,25 +28,18 @@ abstract class AbstractUri implements UriInterface
|
|||
|
||||
/** @var string Uri scheme. */
|
||||
private $scheme = '';
|
||||
|
||||
/** @var string Uri user. */
|
||||
private $user = '';
|
||||
|
||||
/** @var string Uri password. */
|
||||
private $password = '';
|
||||
|
||||
/** @var string Uri host. */
|
||||
private $host = '';
|
||||
|
||||
/** @var int|null Uri port. */
|
||||
private $port;
|
||||
|
||||
/** @var string Uri path. */
|
||||
private $path = '';
|
||||
|
||||
/** @var string Uri query string (without ?). */
|
||||
private $query = '';
|
||||
|
||||
/** @var string Uri fragment (without #). */
|
||||
private $fragment = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class ServerRequest implements ServerRequestInterface
|
|||
* Note: This method is not part of the PSR-7 standard.
|
||||
*
|
||||
* @param string $key The parameter key.
|
||||
* @param string $default The default value.
|
||||
* @param string|null $default The default value.
|
||||
*
|
||||
* @return mixed The parameter value.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ namespace Grav\Framework\Psr7;
|
|||
use Grav\Framework\Psr7\Traits\StreamDecoratorTrait;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Class Stream
|
||||
* @package Grav\Framework\Psr7
|
||||
*/
|
||||
class Stream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\Psr7\Traits;
|
|||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Trait ServerRequestDecoratorTrait
|
||||
* @package Grav\Framework\Psr7\Traits
|
||||
*/
|
||||
trait ServerRequestDecoratorTrait
|
||||
{
|
||||
use RequestDecoratorTrait;
|
||||
|
|
@ -101,6 +105,10 @@ trait ServerRequestDecoratorTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
* @return ServerRequestInterface
|
||||
*/
|
||||
public function withAttributes(array $attributes)
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ namespace Grav\Framework\Psr7\Traits;
|
|||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Trait StreamDecoratorTrait
|
||||
* @package Grav\Framework\Psr7\Traits
|
||||
*/
|
||||
trait StreamDecoratorTrait
|
||||
{
|
||||
/** @var StreamInterface */
|
||||
|
|
@ -26,6 +30,9 @@ trait StreamDecoratorTrait
|
|||
return $this->stream->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->stream->close();
|
||||
|
|
|
|||
|
|
@ -14,36 +14,58 @@ namespace Grav\Framework\Psr7\Traits;
|
|||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* Trait UploadedFileDecoratorTrait
|
||||
* @package Grav\Framework\Psr7\Traits
|
||||
*/
|
||||
trait UploadedFileDecoratorTrait
|
||||
{
|
||||
/** @var UploadedFileInterface */
|
||||
protected $uploadedFile;
|
||||
|
||||
/**
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function getStream(): StreamInterface
|
||||
{
|
||||
return $this->uploadedFile->getStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $targetPath
|
||||
*/
|
||||
public function moveTo($targetPath): void
|
||||
{
|
||||
$this->uploadedFile->moveTo($targetPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getSize(): ?int
|
||||
{
|
||||
return $this->uploadedFile->getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getError(): int
|
||||
{
|
||||
return $this->uploadedFile->getError();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClientFilename(): ?string
|
||||
{
|
||||
return $this->uploadedFile->getClientFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClientMediaType(): ?string
|
||||
{
|
||||
return $this->uploadedFile->getClientMediaType();
|
||||
|
|
|
|||
|
|
@ -13,56 +13,91 @@ namespace Grav\Framework\Psr7\Traits;
|
|||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* Trait UriDecorationTrait
|
||||
* @package Grav\Framework\Psr7\Traits
|
||||
*/
|
||||
trait UriDecorationTrait
|
||||
{
|
||||
/** @var UriInterface */
|
||||
protected $uri;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->uri->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getScheme(): string
|
||||
{
|
||||
return $this->uri->getScheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthority(): string
|
||||
{
|
||||
return $this->uri->getAuthority();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUserInfo(): string
|
||||
{
|
||||
return $this->uri->getUserInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost(): string
|
||||
{
|
||||
return $this->uri->getHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPort(): ?int
|
||||
{
|
||||
return $this->uri->getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->uri->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getQuery(): string
|
||||
{
|
||||
return $this->uri->getQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFragment(): string
|
||||
{
|
||||
return $this->uri->getFragment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scheme
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withScheme($scheme): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
@ -72,6 +107,11 @@ trait UriDecorationTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string|null $password
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withUserInfo($user, $password = null): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
@ -81,6 +121,10 @@ trait UriDecorationTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withHost($host): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
@ -90,6 +134,10 @@ trait UriDecorationTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $port
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withPort($port): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
@ -99,6 +147,10 @@ trait UriDecorationTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withPath($path): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
@ -108,6 +160,10 @@ trait UriDecorationTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withQuery($query): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
@ -117,6 +173,10 @@ trait UriDecorationTrait
|
|||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fragment
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function withFragment($fragment): UriInterface
|
||||
{
|
||||
$new = clone $this;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ use Grav\Framework\Psr7\Traits\UploadedFileDecoratorTrait;
|
|||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* Class UploadedFile
|
||||
* @package Grav\Framework\Psr7
|
||||
*/
|
||||
class UploadedFile implements UploadedFileInterface
|
||||
{
|
||||
use UploadedFileDecoratorTrait;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ use Grav\Framework\Uri\UriFactory;
|
|||
use GuzzleHttp\Psr7\Uri as GuzzleUri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* Class Uri
|
||||
* @package Grav\Framework\Psr7
|
||||
*/
|
||||
class Uri implements UriInterface
|
||||
{
|
||||
use UriDecorationTrait;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user