diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-21 16:22:00 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-21 16:22:00 +0200 |
commit | 93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f (patch) | |
tree | 41bf339ae92784b76cc5adeeb68844a428e7a4fb | |
parent | db3e19a76a2335c9cf88fb08441b35e0cc3648fc (diff) | |
download | blog-93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f.tar.gz blog-93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f.tar.xz blog-93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f.zip |
Add function generatePseudoGUID
-rw-r--r-- | core/functions.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/functions.php b/core/functions.php index 519e5f1..ca13e3d 100644 --- a/core/functions.php +++ b/core/functions.php @@ -104,6 +104,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] #=============================================================================== function parseDatetime($datetime, $format): string { |