mirror of
https://github.com/getgrav/grav.git
synced 2026-07-07 04:43:11 +02:00
Fixed creating new Flex User with file storage
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* Fixed `Flex Pages` with `00.home` page not having ordering set
|
||||
* Fixed `Flex Pages` not updating empty content on save [#2890](https://github.com/getgrav/grav/issues/2890)
|
||||
* Fixed creating new Flex User with file storage
|
||||
* Fixed saving new `Flex Object` with custom key
|
||||
|
||||
# v1.7.0-rc.8
|
||||
## 03/19/2020
|
||||
|
||||
@@ -118,15 +118,15 @@ class UserIndex extends FlexIndex
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $entry
|
||||
* @param array $meta
|
||||
* @param array $data
|
||||
*/
|
||||
protected static function updateIndexData(array &$entry, array $data)
|
||||
public static function updateObjectMeta(array &$meta, array $data)
|
||||
{
|
||||
// Username can also be number and stored as such.
|
||||
$key = (string)($data['username'] ?? $entry['key']);
|
||||
$entry['key'] = mb_strtolower($key);
|
||||
$entry['email'] = isset($data['email']) ? mb_strtolower($data['email']) : null;
|
||||
$key = (string)($data['username'] ?? $meta['key']);
|
||||
$meta['key'] = mb_strtolower($key);
|
||||
$meta['email'] = isset($data['email']) ? mb_strtolower($data['email']) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,6 +69,15 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
return $storage->getExistingKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $meta
|
||||
* @param array $data
|
||||
*/
|
||||
public static function updateObjectMeta(array &$meta, array $data)
|
||||
{
|
||||
static::updateIndexData($meta, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new FlexIndex.
|
||||
*
|
||||
@@ -676,7 +685,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
if ($keyField !== 'storage_key' && isset($row[$keyField])) {
|
||||
$entry['key'] = $row[$keyField];
|
||||
}
|
||||
static::updateIndexData($entry, $row ?? []);
|
||||
static::updateObjectMeta($entry, $row ?? []);
|
||||
if (isset($row['__ERROR'])) {
|
||||
$entry['__ERROR'] = true;
|
||||
static::onException(new \RuntimeException(sprintf('Object failed to load: %s (%s)', $key,
|
||||
@@ -712,6 +721,11 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
return $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $entry
|
||||
* @param array $data
|
||||
* @deprecated 1.7 Use static ::updateObjectMeta() method instead.
|
||||
*/
|
||||
protected static function updateIndexData(array &$entry, array $data)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -614,6 +614,9 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
||||
$value = reset($result);
|
||||
$meta = $value['__META'] ?? null;
|
||||
if ($meta) {
|
||||
/** @var FlexIndex $indexClass */
|
||||
$indexClass = $this->getFlexDirectory()->getIndexClass();
|
||||
$indexClass::updateObjectMeta($meta, $value);
|
||||
$this->_meta = $meta;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user