mirror of
https://github.com/flextype/flextype.git
synced 2025-08-27 15:00:11 +02:00
feat(entries): add ability to fetch and filter entries by fields with help of array dot path.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user