From 95f3407a38c991d536595946e7c7a18e7772bd04 Mon Sep 17 00:00:00 2001 From: Justin Toupin <justintoupin@Justins-MacBook-Pro.local> Date: Mon, 14 Nov 2022 15:57:30 -0700 Subject: [PATCH] Generate random, unique id and store in protected variable. --- src/LayoutParagraphsLayout.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/LayoutParagraphsLayout.php b/src/LayoutParagraphsLayout.php index 0229aac..1b4faa4 100644 --- a/src/LayoutParagraphsLayout.php +++ b/src/LayoutParagraphsLayout.php @@ -53,6 +53,13 @@ class LayoutParagraphsLayout implements ThirdPartySettingsInterface { */ protected $settings; + /** + * The layout ID. + * + * @var string + */ + protected $id; + /** * Class constructor. * @@ -76,11 +83,10 @@ class LayoutParagraphsLayout implements ThirdPartySettingsInterface { * A unique id. */ public function id() { - $uuid = $this->getEntity()->uuid(); - $langcode = $this->getEntity()->language()->getId(); - $field_name = $this->getFieldName(); - $id = Crypt::hashBase64($uuid . $langcode . $field_name); - return $id; + if (empty($this->id)) { + $this->id = bin2hex(random_bytes(16)); + } + return $this->id; } /** -- GitLab