From d77c3c52ac1b79de9ba43a69605703eaa66cd359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Fri, 10 Nov 2023 13:28:15 +0100 Subject: [PATCH 1/2] Better way to set object name --- src/Ease/Brick.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Ease/Brick.php b/src/Ease/Brick.php index 2c0a175..37feb57 100644 --- a/src/Ease/Brick.php +++ b/src/Ease/Brick.php @@ -6,7 +6,7 @@ * @author Vitex * @copyright 2009-2023 Vitex@hippy.cz (G) * - * PHP 7 + * PHP 7,8 */ declare(strict_types=1); @@ -108,9 +108,14 @@ public function howToProcess($identifer) public function setObjectName($objectName = null) { if (is_null($objectName)) { - $key = $this->getMyKey($this->data); + $recordId = $this->getMyKey($this->data); + if ($this->nameColumn && $this->getDataValue($this->nameColumn)) { + $key = '(' . $recordId . ')' . $this->getDataValue($this->nameColumn); + } else { + $key = $recordId; + } if ($key) { - $result = parent::setObjectName(get_class($this) . '@' . $key); + $result = parent::setObjectName($key . '@' . \Ease\Logger\Message::getCallerName($this)); } else { $result = parent::setObjectName(); } From 9e88bd3b34371911e2669a2fccd99556aca617cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Fri, 10 Nov 2023 13:35:32 +0100 Subject: [PATCH 2/2] Unit test update for object naming --- tests/src/Ease/BrickTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Ease/BrickTest.php b/tests/src/Ease/BrickTest.php index 7ff40ff..c6cd82f 100644 --- a/tests/src/Ease/BrickTest.php +++ b/tests/src/Ease/BrickTest.php @@ -62,7 +62,7 @@ public function testSetObjectName() $this->object->setMyKey(123); $this->object->setObjectName(); $this->assertEquals( - get_class($this->object) . '@123', + '123@' . get_class($this->object), $this->object->getObjectName() ); $this->object->setObjectName('customBrick');