commit 5eab8a20e11ddf9a226dafebac22d56e6ba8daf2
parent 86f4d5db5e91ab9890881765a24668bf39d64c3c
Author: markseu <mark2011@mayberg.se>
Date: Sun, 19 Mar 2023 19:24:54 +0100
Updated API, remove page from collection
Diffstat:
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/system/extensions/core.php b/system/extensions/core.php
@@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core
class YellowCore {
- const VERSION = "0.8.103";
+ const VERSION = "0.8.104";
const RELEASE = "0.8.21";
public $content; // content files
public $media; // media files
@@ -3408,6 +3408,17 @@ class YellowPageCollection extends ArrayObject {
$this->exchangeArray($array);
}
+ // Remove page from page collection
+ public function remove($page): YellowPageCollection {
+ $array = array();
+ $location = $page->location;
+ foreach ($this->getArrayCopy() as $page) {
+ if ($page->location!=$location) array_push($array, $page);
+ }
+ $this->exchangeArray($array);
+ return $this;
+ }
+
// Filter page collection by page setting
public function filter($key, $value, $exactMatch = true): YellowPageCollection {
$array = array();
@@ -3493,7 +3504,7 @@ class YellowPageCollection extends ArrayObject {
// Calculate intersection, remove pages that are not present in another page collection
public function intersect($input): YellowPageCollection {
$callback = function ($a, $b) {
- return strcmp(spl_object_hash($a), spl_object_hash($b));
+ return strcmp($a->location, $b->location);
};
$this->exchangeArray(array_uintersect($this->getArrayCopy(), (array)$input, $callback));
return $this;
@@ -3502,7 +3513,7 @@ class YellowPageCollection extends ArrayObject {
// Calculate difference, remove pages that are present in another page collection
public function diff($input): YellowPageCollection {
$callback = function ($a, $b) {
- return strcmp(spl_object_hash($a), spl_object_hash($b));
+ return strcmp($a->location, $b->location);
};
$this->exchangeArray(array_udiff($this->getArrayCopy(), (array)$input, $callback));
return $this;
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
@@ -11,11 +11,11 @@ Tag: feature
system/extensions/command.php: command.php, create, update
Extension: Core
-Version: 0.8.103
+Version: 0.8.104
Description: Core functionality of the website.
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/main/downloads/core.zip
-Published: 2022-11-22 22:27:11
+Published: 2023-03-19 19:20:55
Developer: Mark Seuffert, David Fehrmann
Tag: feature
system/extensions/core.php: core.php, create, update