/** * @return void */ protected function onRetrieveValue() { $params = $this->scriptlet->request->getParams(); $id = $this->id(); $value = null; $hasBeenSubmitted = false; if ($value = $params->containsKey($id)) { $value = $params->get($id); $hasBeenSubmitted = true; } else { if ($value = $params->containsKey("{$id}-value")) { $value = $params->get("{$id}-value"); $hasBeenSubmitted = true; } } if ($hasBeenSubmitted) { if ('null' === $value || null === $value) { $this->value = null; } else { if (null === $this->valueType) { $this->value = $value; } else { $valueType = $this->valueType; if ($value instanceof $valueType) { $this->value = $value; } else { $this->value = $valueType::valueOf($value); } } } } foreach ($this->panelProperties as $property) { if ($params->containsKey("{$id}-{$property}")) { if (($value = $params->get("{$id}-{$property}")) && 'null' !== $value) { if (is_scalar($this->{$property})) { $this->{$property} = Primitive::castTo(gettype($this->{$property}), $value); } else { $this->{$property} = json_decode($value); } } else { $this->{$property} = null; } } } foreach ($this->panelPropertiesToggle as $property) { if ($params->containsKey("{$id}-{$property}")) { $value = $params->get("{$id}-{$property}"); if (in_array($value, ['1', 'true', $property])) { $this->{$property} = true; } else { $this->{$property} = false; } } } }