Skip to content

Commit

Permalink
UI: fix backwards compatibility for Data/Table backport
Browse files Browse the repository at this point in the history
The method isClientSideValueOk changing from protected to public made plugins
break that implemented their own inputs. When switching back the method to public,
unit tests fail, indicating that we cross class hierarchies when calling the
method. This was due to the fact that we indeed had two different methods
isClientSideValueOk, one from the original input hierarchy, one from a trait
for groups. These are reconciled now and thus the method can be protected again.
  • Loading branch information
klees committed May 16, 2024
1 parent fb0b85d commit 00d95a6
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function getConstraintForRequirement(): ?Constraint
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if ($value == "checked" || $value === "" || is_bool($value)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getTimeOnly(): bool
return $this->with_time_only;
}

public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return is_string($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function getTimezone(): ?string
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function ($txt, $value) {
);
}

public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if (!is_array($value)) {
return false;
Expand Down
6 changes: 6 additions & 0 deletions src/UI/Implementation/Component/Input/Field/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,10 @@ protected function getDataFactory(): DataFactory
{
return $this->data_factory;
}

/** ATTENTION: @see GroupInternals::_isClientSideValueOk() */
protected function isClientSideValueOk($value): bool
{
return $this->_isClientSideValueOk($value);
}
}
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function getConstraintForRequirement(): ?Constraint
return null;
}

public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function addTransformation(): void
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getOptions(): array
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if (is_null($value)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Numeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return is_numeric($value) || $value === "" || $value === null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function getConstraintForRequirement(): ?Constraint
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if ($value === null) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return is_string($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Radio extends FormInput implements C\Input\Field\Radio
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return ($value === '' || array_key_exists($value, $this->getOptions()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getOptions(): array
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return in_array($value, array_keys($this->options)) || $value == "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function getConstraintForRequirement(): ?Constraint
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if (!is_string($value) && !is_int($value)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function getConstraintForRequirement(): ?Constraint
/**
* @inheritDoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if ($this->getMaxTags() > 0) {
$max_tags = $this->getMaxTags();
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getMaxLength(): ?int
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if (!is_string($value)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getMinLimit(): ?int
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return is_string($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Field/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static function getURIChecker(): Closure
/**
* @inheritdoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
if (is_string($value) && trim($value) === "") {
return true;
Expand Down
6 changes: 4 additions & 2 deletions src/UI/Implementation/Component/Input/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ protected function nameInputs(NameSource $source, string $parent_name): array
}

/**
* @inheritdoc
* ATTENTION: This is not the same as @see Input::isClientSideValueOk(),
* even if it had the same name. These are different symbols, as this trait
* is not in the hierarchy that defines the original isClientSideValueOk.
*/
public function isClientSideValueOk($value): bool
protected function _isClientSideValueOk($value): bool
{
if (!is_array($value)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Implementation/Component/Input/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function withValue($value): self
*
* @param mixed $value
*/
abstract public function isClientSideValueOk($value): bool;
abstract protected function isClientSideValueOk($value): bool;

/**
* The error of the input as used in HTML.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
$this->internal_selection_signal = $signal_generator->create();
}

public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return is_null($value) || is_array($value);
}
Expand Down
6 changes: 6 additions & 0 deletions src/UI/Implementation/Component/Input/ViewControl/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,10 @@ protected function getDataFactory(): DataFactory
{
return $this->data_factory;
}

/** ATTENTION: @see GroupInternals::_isClientSideValueOk() */
protected function isClientSideValueOk($value): bool
{
return $this->_isClientSideValueOk($value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getContent(): Result
/**
* @inheritDoc
*/
public function isClientSideValueOk($value): bool
protected function isClientSideValueOk($value): bool
{
return $this->input_group->isClientSideValueOk($value);
}
Expand Down

0 comments on commit 00d95a6

Please sign in to comment.