From 93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 21 Jun 2021 16:22:00 +0200 Subject: Add function generatePseudoGUID --- core/functions.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'core') diff --git a/core/functions.php b/core/functions.php index 519e5f1..ca13e3d 100644 --- a/core/functions.php +++ b/core/functions.php @@ -103,6 +103,28 @@ function generateItemTemplateData(Item $Item): array { ]; } +#=============================================================================== +# Generate pseudo GUID for entity +#=============================================================================== +function generatePseudoGUID(Item $Entity) { + switch(get_class($Entity)) { + case "Page\Item": + $attr = Application::get('PAGE.FEED_GUID'); + break; + case "Post\Item": + $attr = Application::get('POST.FEED_GUID'); + break; + default: + $attr = ['id', 'time_insert']; + } + + foreach($attr as $attribute) { + $attributes[] = $Entity->attr($attribute); + } + + return sha1(implode('', $attributes)); +} + #=============================================================================== # Parser for datetime formatted strings [YYYY-MM-DD HH:II:SS] #=============================================================================== -- cgit v1.2.3