User Create/Edit/Invite frontend + backend

This commit is contained in:
2024-05-03 23:07:50 +02:00
parent 675025800b
commit 91520dd26c
6 changed files with 195 additions and 62 deletions

View File

@@ -16,14 +16,16 @@ class ArrayType extends Parameter {
* @param bool $optional true if the parameter is optional
* @param array|null $defaultValue the default value to use, if the parameter is not given
*/
public function __construct(string $name, int $elementType = Parameter::TYPE_MIXED, bool $canBeOne = false, bool $optional = FALSE, ?array $defaultValue = NULL) {
public function __construct(string $name, int $elementType = Parameter::TYPE_MIXED, bool $canBeOne = false,
bool $optional = FALSE, ?array $defaultValue = NULL, ?array $choices = NULL) {
$this->elementType = $elementType;
$this->elementParameter = new Parameter('', $elementType);
$this->canBeOne = $canBeOne;
parent::__construct($name, Parameter::TYPE_ARRAY, $optional, $defaultValue);
parent::__construct($name, Parameter::TYPE_ARRAY, $optional, $defaultValue, $choices);
}
public function parseParam($value): bool {
if (!is_array($value)) {
if (!$this->canBeOne) {
return false;
@@ -42,6 +44,14 @@ class ArrayType extends Parameter {
}
}
if (!is_null($this->choices)) {
foreach ($value as $element) {
if (!in_array($element, $this->choices)) {
return false;
}
}
}
$this->value = $value;
return true;
}