mirror of
https://github.com/getgrav/grav.git
synced 2026-03-03 11:01:30 +01:00
FlexDirectory::getObject() can now be called without any parameters to create a new object
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
1. [](#improved)
|
||||
* Better support for Symfony local server `symfony server:start`
|
||||
* Make `Route` objects immutable
|
||||
* `FlexDirectory::getObject()` can now be called without any parameters to create a new object
|
||||
1. [](#bugfix)
|
||||
* Fixed `Form` not to use deleted flash object until the end of the request fixing issues with reset
|
||||
* Fixed `FlexForm` to allow multiple form instances with non-existing objects
|
||||
|
||||
@@ -222,7 +222,7 @@ class FlexDirectory implements FlexAuthorizeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object if it exists.
|
||||
* 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.
|
||||
*
|
||||
@@ -230,8 +230,12 @@ class FlexDirectory implements FlexAuthorizeInterface
|
||||
* @param string|null $keyField Field to be used as the key.
|
||||
* @return FlexObjectInterface|null
|
||||
*/
|
||||
public function getObject($key, string $keyField = null): ?FlexObjectInterface
|
||||
public function getObject($key = null, string $keyField = null): ?FlexObjectInterface
|
||||
{
|
||||
if (null === $key && null === $keyField) {
|
||||
return $this->createObject([], '');
|
||||
}
|
||||
|
||||
return $this->getIndex(null, $keyField)->get($key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user