From a2fbe68a601079bea5cb31f4d7ab65d774d9461f Mon Sep 17 00:00:00 2001 From: Maxim Yugov Date: Tue, 4 Nov 2025 18:27:23 +0300 Subject: [PATCH 1/2] Fix entity.get method --- .../Entity/Entity/Result/EntitiesResult.php | 8 +++++++- .../Entity/Entity/Service/EntityTest.php | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Services/Entity/Entity/Result/EntitiesResult.php b/src/Services/Entity/Entity/Result/EntitiesResult.php index 9b539a1e..13eaaf1e 100644 --- a/src/Services/Entity/Entity/Result/EntitiesResult.php +++ b/src/Services/Entity/Entity/Result/EntitiesResult.php @@ -25,7 +25,13 @@ class EntitiesResult extends AbstractResult public function getEntities(): array { $res = []; - foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) { + $entities = $this->getCoreResponse()->getResponseData()->getResult(); + + if (isset($entities['ID'])) { + return [new EntityItemResult($entities)]; + } + + foreach ($entities as $item) { $res[] = new EntityItemResult($item); } diff --git a/tests/Integration/Services/Entity/Entity/Service/EntityTest.php b/tests/Integration/Services/Entity/Entity/Service/EntityTest.php index b78671ae..e0ea1708 100644 --- a/tests/Integration/Services/Entity/Entity/Service/EntityTest.php +++ b/tests/Integration/Services/Entity/Entity/Service/EntityTest.php @@ -91,6 +91,22 @@ public function testGet(): void $this->assertTrue($this->sb->getEntityScope()->entity()->delete($entity)->isSuccess()); } + public function testGetEntity(): void + { + $entity = (string)time(); + $this->assertTrue( + $this->sb->getEntityScope()->entity()->add( + $entity, + 'test entity', + [] + )->isSuccess() + ); + $entities = $this->sb->getEntityScope()->entity()->get($entity)->getEntities(); + $this->assertContains($entity, array_column($entities, 'ENTITY')); + + $this->assertTrue($this->sb->getEntityScope()->entity()->delete($entity)->isSuccess()); + } + public function testRights(): void { $entity = (string)time(); From daa9cdcf138b2cf627694fbf23abbc8bcca755b9 Mon Sep 17 00:00:00 2001 From: Maxim Yugov Date: Wed, 5 Nov 2025 19:54:36 +0300 Subject: [PATCH 2/2] Added info to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c58edb0..7b2157cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1060,6 +1060,7 @@ Supported in bitrix24-php-sdk methods with batch wrapper count: 22 - Fixed variable names in `Bitrix24\SDK\Services\ServiceBuilderFactory::initFromRequest`, see [wrong variable name](https://github.com/bitrix24/b24phpsdk/issues/30). - Fixed some corner cases in `Bitrix24\SDK\Core\ApiLevelErrorHandler` +- Fixed getting entity by its code, see [entity.get issue](https://github.com/bitrix24/b24phpsdk/issues/285)