From 149324d63a6245f2178ba6f5ef6854cc1dd5d889 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 25 Jun 2020 20:48:50 +0300 Subject: [PATCH] feat(entries): add ability to fetch and filter entries by fields with help of array dot path. --- src/flextype/core/Entries/Entries.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/flextype/core/Entries/Entries.php b/src/flextype/core/Entries/Entries.php index 1067ed0a..cde5f011 100755 --- a/src/flextype/core/Entries/Entries.php +++ b/src/flextype/core/Entries/Entries.php @@ -14,6 +14,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; use Flextype\Component\Filesystem\Filesystem; use Flextype\Component\Session\Session; +use Flextype\Component\Arr\Arr; use Ramsey\Uuid\Uuid; use function array_merge; use function count; @@ -391,6 +392,9 @@ class Entries // For each founded entry we should create $entries array. $entry = $this->fetch($uid); + // Flatten a multi-dimensional entries array with dots. + $entry = Arr::dot($entry); + // Add entry into the entries $entries[$uid] = $entry; @@ -483,6 +487,11 @@ class Entries // Gets a native PHP array representation of the collection. $entries = $entries->toArray(); + // Magic is here... dot and undot for entries array + // 1. Flatten a multi-dimensional entries array with dots. + // 2. Restore entries array with dots into correct multi-dimensional entries array + $entries = Arr::undot(Arr::dot($entries)); + // Restore error_reporting error_reporting($oldErrorReporting);