Update 2024-07-11 23:11:32

This commit is contained in:
Robot 2024-07-11 23:15:28 +02:00
parent 0160c64a63
commit 5d28565ce7
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
6 changed files with 22 additions and 10 deletions

View File

@ -13,7 +13,7 @@
@startuml @startuml
interface MultiSubformInterface #Lavender { interface MultiSubformInterface #Lavender {
+ get(array $getMap) : ?array + get(array $getMap) : ?array
+ set(array $items, array $setMap) : bool + set(mixed $items, array $setMap) : bool
} }
note right of MultiSubformInterface::get note right of MultiSubformInterface::get

View File

@ -49,7 +49,7 @@ interface MultiSubformInterface
/** /**
* Set a subform items * Set a subform items
* *
* @param array $items The list of items from the subform to set * @param mixed $items The list of items from the subform to set
* @param array $setMap The the map to set the subfrom data * @param array $setMap The the map to set the subfrom data
* *
* Example: * Example:
@ -72,6 +72,6 @@ interface MultiSubformInterface
* @return bool * @return bool
* @since 3.2.2 * @since 3.2.2
*/ */
public function set(array $items, array $setMap): bool; public function set(mixed $items, array $setMap): bool;
} }

View File

@ -28,7 +28,7 @@
/** /**
* Set a subform items * Set a subform items
* *
* @param array $items The list of items from the subform to set * @param mixed $items The list of items from the subform to set
* @param array $setMap The the map to set the subfrom data * @param array $setMap The the map to set the subfrom data
* *
* Example: * Example:
@ -51,4 +51,4 @@
* @return bool * @return bool
* @since 3.2.2 * @since 3.2.2
*/ */
public function set(array $items, array $setMap): bool; public function set(mixed $items, array $setMap): bool;

View File

@ -15,7 +15,7 @@ class MultiSubform << (F,LightGreen) >> #RoyalBlue {
# Subform $subform # Subform $subform
+ __construct(Subform $subform) + __construct(Subform $subform)
+ get(array $getMap) : ?array + get(array $getMap) : ?array
+ set(array $items, array $setMap) : bool + set(mixed $items, array $setMap) : bool
- getSubformData(array $map, ?array $coreData = null) : ?array - getSubformData(array $map, ?array $coreData = null) : ?array
- setSubformData(array $items, array $map, ...) : bool - setSubformData(array $items, array $map, ...) : bool
- setLinkValue(string $linkValue, ?array $data = null) : ?string - setLinkValue(string $linkValue, ?array $data = null) : ?string

View File

@ -94,7 +94,7 @@ final class MultiSubform implements MultiSubformInterface
/** /**
* Set a subform items * Set a subform items
* *
* @param array $items The list of items from the subform to set * @param mixed $items The list of items from the subform to set
* @param array $setMap The the map to set the subfrom data * @param array $setMap The the map to set the subfrom data
* *
* Example: * Example:
@ -117,7 +117,7 @@ final class MultiSubform implements MultiSubformInterface
* @return bool * @return bool
* @since 3.2.2 * @since 3.2.2
*/ */
public function set(array $items, array $setMap): bool public function set(mixed $items, array $setMap): bool
{ {
// Validate the core map presence and structure // Validate the core map presence and structure
if (!isset($setMap['_core']) || !is_array($setMap['_core']) || !$this->validSetMap($setMap['_core'])) if (!isset($setMap['_core']) || !is_array($setMap['_core']) || !$this->validSetMap($setMap['_core']))
@ -125,6 +125,12 @@ final class MultiSubform implements MultiSubformInterface
return false; return false;
} }
// catch an empty set
if (!is_array($items))
{
$items = []; // will delete all exisitng linked items :( not ideal, but real
}
// Save the core data // Save the core data
if (!$this->setSubformData($items, $setMap['_core'])) if (!$this->setSubformData($items, $setMap['_core']))
{ {

View File

@ -69,7 +69,7 @@
/** /**
* Set a subform items * Set a subform items
* *
* @param array $items The list of items from the subform to set * @param mixed $items The list of items from the subform to set
* @param array $setMap The the map to set the subfrom data * @param array $setMap The the map to set the subfrom data
* *
* Example: * Example:
@ -92,7 +92,7 @@
* @return bool * @return bool
* @since 3.2.2 * @since 3.2.2
*/ */
public function set(array $items, array $setMap): bool public function set(mixed $items, array $setMap): bool
{ {
// Validate the core map presence and structure // Validate the core map presence and structure
if (!isset($setMap['_core']) || !is_array($setMap['_core']) || !$this->validSetMap($setMap['_core'])) if (!isset($setMap['_core']) || !is_array($setMap['_core']) || !$this->validSetMap($setMap['_core']))
@ -100,6 +100,12 @@
return false; return false;
} }
// catch an empty set
if (!is_array($items))
{
$items = []; // will delete all exisitng linked items :( not ideal, but real
}
// Save the core data // Save the core data
if (!$this->setSubformData($items, $setMap['_core'])) if (!$this->setSubformData($items, $setMap['_core']))
{ {