From 08d924b53e88773e4e3ca1be6d720fc14f757b07 Mon Sep 17 00:00:00 2001 From: Dmitrii Fediuk Date: Mon, 3 Jun 2024 01:57:37 +0100 Subject: [PATCH] https://github.com/mage2pro/core/issues/403 --- app/code/local/Df/Core/lib/array/find.php | 49 +++++++++++++++++------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/app/code/local/Df/Core/lib/array/find.php b/app/code/local/Df/Core/lib/array/find.php index b41a01700c..cc87e5d56c 100644 --- a/app/code/local/Df/Core/lib/array/find.php +++ b/app/code/local/Df/Core/lib/array/find.php @@ -1,40 +1,51 @@ $v) {/** @var int|string $k */ /** @var mixed $v */ /** @var mixed[] $primaryArgument */ @@ -53,5 +64,17 @@ function df_find($a1, $a2, $pAppend = [], $pPrepend = [], $keyPosition = 0) { break; } } + # 2023-07-25 + # 1) "Adapt `df_find` to the nested search": https://github.com/mage2pro/core/issues/251 + # 2) I implement the nested seach in a separate loop to minimize recursions. + if (null === $r && $nested) { + foreach ($a as $v) {/** @var int|string $k */ /** @var mixed $v */ /** @var mixed[] $primaryArgument */ + if (is_iterable($v)) { + if ($r = df_find($v, $f, $pAppend, $pPrepend, $keyPosition, true)) { + break; + } + } + } + } return $r; } \ No newline at end of file