Added support for flex-required@: not exists and flex-required@: '!exists' in blueprints

This commit is contained in:
Matias Griese
2021-09-09 14:14:16 +03:00
parent cda08242f1
commit 21db2e7d4a
4 changed files with 27 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
* Added `|yaml` filter to convert input to YAML
* Added `route` and `request` to `onPageNotFound` event
* Added file upload/remove support for `Flex Forms`
* Added support for `flex-required@: not exists` and `flex-required@: '!exists'` in blueprints
* Throwing exceptions from Twig templates fires `onDisplayErrorPage.[code]` event allowing better error pages
3. [](#bugfix)
* Fixed escaping in PageIndex::getLevelListing()

View File

@@ -41,6 +41,14 @@ class UserGroupObject extends FlexObject implements UserGroupInterface
] + parent::getCachedMethods();
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->getProperty('readableName');
}
/**
* Checks user authorization to the action.
*

View File

@@ -306,6 +306,14 @@ class UserObject extends FlexObject implements UserInterface, Countable
return $value;
}
/**
* @return UserGroupIndex
*/
public function getRoles(): UserGroupIndex
{
return $this->getGroups();
}
/**
* Convert object into an array.
*

View File

@@ -836,13 +836,22 @@ class FlexDirectory implements FlexDirectoryInterface
$params = (array)$call['params'];
$object = $call['object'] ?? null;
$method = array_shift($params);
$not = false;
if (str_starts_with($method, '!')) {
$method = substr($method, 1);
$not = true;
} elseif (str_starts_with($method, 'not ')) {
$method = substr($method, 4);
$not = true;
}
$method = trim($method);
if ($object && method_exists($object, $method)) {
$value = $object->{$method}(...$params);
if (is_array($value) && isset($field[$property]) && is_array($field[$property])) {
$value = $this->mergeArrays($field[$property], $value);
}
$field[$property] = $value;
$field[$property] = $not ? !$value : $value;
}
}