mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 874007ddbebc693ec5888ef2dfe4819c0438641d
parent 005ced1bcc3afd2c7339515bc5c6199d538d66fb
Author: markseu <mark2011@mayberg.se>
Date:   Thu,  7 Nov 2019 00:02:41 +0100

Updated API, remove pages from collectio

Diffstat:
Msystem/extensions/core.php | 20+++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -1003,12 +1003,30 @@ class YellowPageCollection extends ArrayObject { return $this; } - // Merge page collection + // Calculate union, merge page collection public function merge($input) { $this->exchangeArray(array_merge($this->getArrayCopy(), (array)$input)); return $this; } + // Calculate intersection, remove pages that are not present in another page collection + public function intersect($input) { + $callback = function ($a, $b) { + return strcmp(spl_object_hash($a), spl_object_hash($b)); + }; + $this->exchangeArray(array_uintersect($this->getArrayCopy(), (array)$input, $callback)); + return $this; + } + + // Calculate difference, remove pages that are present in another page collection + public function diff($input) { + $callback = function ($a, $b) { + return strcmp(spl_object_hash($a), spl_object_hash($b)); + }; + $this->exchangeArray(array_udiff($this->getArrayCopy(), (array)$input, $callback)); + return $this; + } + // Append to end of page collection public function append($page) { parent::append($page);