Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Sep 6, 2023
2 parents 870ba86 + c50751c commit f8b5220
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": "^8.1",
"netgen/layouts-core": "~1.4.3",
"netgen/layouts-core": "~1.4.5",
"netgen/content-browser-ibexa": "^1.4",
"ibexa/core": "^4.4",
"ibexa/admin-ui": "^4.4",
Expand Down
6 changes: 5 additions & 1 deletion lib/Parameters/ValueObjectProvider/ContentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public function __construct(private Repository $repository, private ErrorHandler

public function getValueObject(mixed $value): ?Content
{
if ($value === null) {
return null;
}

try {
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */
$content = $this->repository->sudo(
Expand All @@ -26,7 +30,7 @@ public function getValueObject(mixed $value): ?Content

return $content->contentInfo->mainLocationId !== null ? $content : null;
} catch (NotFoundException $e) {
$this->errorHandler->handleError($e);
$this->errorHandler->logError($e);

return null;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/Parameters/ValueObjectProvider/LocationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ public function __construct(private Repository $repository, private ErrorHandler

public function getValueObject(mixed $value): ?Location
{
if ($value === null) {
return null;
}

try {
return $this->repository->sudo(
fn (): Location => $this->repository->getLocationService()->loadLocation((int) $value),
);
} catch (NotFoundException $e) {
$this->errorHandler->handleError($e);
$this->errorHandler->logError($e);

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public function testGetValueObject(): void
self::assertSame($content, $this->valueObjectProvider->getValueObject(42));
}

public function testGetValueObjectWithNullValue(): void
{
$this->contentServiceMock
->expects(self::never())
->method('loadContent');

self::assertNull($this->valueObjectProvider->getValueObject(null));
}

public function testGetValueObjectWithNonExistentLocation(): void
{
$this->contentServiceMock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ public function testGetValueObject(): void
self::assertSame($location, $this->valueObjectProvider->getValueObject(42));
}

public function testGetValueObjectWithNullValue(): void
{
$this->locationServiceMock
->expects(self::never())
->method('loadLocation');

self::assertNull($this->valueObjectProvider->getValueObject(null));
}

public function testGetValueObjectWithNonExistentLocation(): void
{
$this->locationServiceMock
Expand Down

0 comments on commit f8b5220

Please sign in to comment.