FlexDirectory::getObject() can now be called without any parameters to create a new object

This commit is contained in:
Matias Griese
2019-07-12 12:40:23 +03:00
parent 66c17a8f53
commit 95c58c8361
2 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -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);
}