Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!--
### Deprecated
Expand Down
8 changes: 7 additions & 1 deletion src/Services/Entity/Entity/Result/EntitiesResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
16 changes: 16 additions & 0 deletions tests/Integration/Services/Entity/Entity/Service/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down