Skip to content

Commit

Permalink
NGSTACK-842 support Ibexa 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
petarjakopec committed Jun 26, 2024
1 parent 7e23217 commit 823dd0d
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bundle/Core/Exception/InvalidStateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class InvalidStateException extends Exception
{
public function __construct(Content $content, ?Exception $previous = null)
{
$message = sprintf("Content '%s' with id #%d is not valid for scheduled visibility update.", $content->getName(), $content->getId());
$message = sprintf("Content '%s' with id #%d is not valid for scheduled visibility update.", $content->getName(), $content->id);

parent::__construct($message, 0, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/Core/ScheduledVisibilityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function logUpdate(Content $content, VisibilityUpdateResult $updateResul
sprintf(
"Content '%s' with id #%d has been %s.",
$content->getName(),
$content->getId(),
$content->id,
$updateResult->value,
),
);
Expand Down
8 changes: 4 additions & 4 deletions bundle/Core/VisibilityHandler/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ public function __construct(
public function hide(ContentValue $content): void
{
$this->repository->sudo(
fn () => $this->contentService->hideContent($content->getContentInfo()),
fn () => $this->contentService->hideContent($content->contentInfo),
);
}

public function reveal(ContentValue $content): void
{
$this->repository->sudo(
fn () => $this->contentService->revealContent($content->getContentInfo()),
fn () => $this->contentService->revealContent($content->contentInfo),
);
}

public function isHidden(ContentValue $content): bool
{
return $content->getContentInfo()->isHidden();
return $content->contentInfo->isHidden;
}

public function isVisible(ContentValue $content): bool
{
return !$content->getContentInfo()->isHidden();
return !$content->contentInfo->isHidden;
}
}
9 changes: 5 additions & 4 deletions bundle/Core/VisibilityHandler/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function hide(Content $content): void
{
$this->repository->sudo(
function () use ($content): void {
$locations = $this->locationService->loadLocations($content->getContentInfo());
$locations = $this->locationService->loadLocations($content->contentInfo);

foreach ($locations as $location) {
$this->locationService->hideLocation($location);
Expand All @@ -33,7 +33,7 @@ public function reveal(Content $content): void
{
$this->repository->sudo(
function () use ($content): void {
$locations = $this->locationService->loadLocations($content->getContentInfo());
$locations = $this->locationService->loadLocations($content->contentInfo);

foreach ($locations as $location) {
$this->locationService->unhideLocation($location);
Expand All @@ -50,11 +50,12 @@ public function isHidden(Content $content): bool
public function isVisible(Content $content): bool
{
$locations = $this->repository->sudo(
fn () => $this->locationService->loadLocations($content->getContentInfo()),
fn () => $this->locationService->loadLocations($content->contentInfo),
);

/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */
foreach ($locations as $location) {
if ($location->isHidden()) {
if ($location->hidden) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions bundle/Core/VisibilityHandler/ObjectState.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function () use ($content, $objectStateId): void {
$objectStateGroup = $objectState->getObjectStateGroup();

$this->objectStateService->setContentState(
$content->getContentInfo(),
$content->contentInfo,
$objectStateGroup,
$objectState,
);
Expand All @@ -73,7 +73,7 @@ private function getObjectState(Content $content): ObjectStateValue
function () use ($content, $objectStateGroupId): ObjectStateValue {
$objectStateGroup = $this->objectStateService->loadObjectStateGroup($objectStateGroupId);

return $this->objectStateService->getContentState($content->getContentInfo(), $objectStateGroup);
return $this->objectStateService->getContentState($content->contentInfo, $objectStateGroup);
},
);
}
Expand Down
6 changes: 3 additions & 3 deletions bundle/Core/VisibilityHandler/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function reveal(Content $content): void

public function isHidden(Content $content): bool
{
return $content->getContentInfo()->getSectionId() === $this->hiddenSectionId;
return $content->contentInfo->sectionId === $this->hiddenSectionId;
}

public function isVisible(Content $content): bool
{
return $content->getContentInfo()->getSectionId() === $this->visibleSectionId;
return $content->contentInfo->sectionId === $this->visibleSectionId;
}

private function assignSection(Content $content, int $sectionId): void
Expand All @@ -48,7 +48,7 @@ private function assignSection(Content $content, int $sectionId): void
function () use ($content, $sectionId): void {
$section = $this->sectionService->loadSection($sectionId);

$this->sectionService->assignSection($content->getContentInfo(), $section);
$this->sectionService->assignSection($content->contentInfo, $section);
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/bundle/Integration/ContentAndLocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testUpdateVisibility(array $configuration, bool $expectedHidden)
if ($scheduledVisibilityService->shouldBeVisible($content) && $handler->isHidden($content)) {
$handler->reveal($content);
}
$content = $this->getRepository()->getContentService()->loadContent($content->getContentInfo()->getId());
$content = $this->getRepository()->getContentService()->loadContent($content->contentInfo->id);
self::assertEquals($handler->isHidden($content), $expectedHidden);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bundle/Integration/ContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testUpdateVisibility(array $configuration, bool $expectedHidden)
if ($scheduledVisibilityService->shouldBeVisible($content) && $handler->isHidden($content)) {
$handler->reveal($content);
}
$content = $this->getRepository()->getContentService()->loadContent($content->getContentInfo()->getId());
$content = $this->getRepository()->getContentService()->loadContent($content->contentInfo->id);
self::assertEquals($handler->isHidden($content), $expectedHidden);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bundle/Integration/LocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testUpdateVisibility(array $configuration, bool $expectedHidden)
if ($scheduledVisibilityService->shouldBeVisible($content) && $handler->isHidden($content)) {
$handler->reveal($content);
}
$content = $this->getRepository()->getContentService()->loadContent($content->getContentInfo()->getId());
$content = $this->getRepository()->getContentService()->loadContent($content->contentInfo->id);
self::assertEquals($handler->isHidden($content), $expectedHidden);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/bundle/Integration/ObjectStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function testUpdateVisibility(array $configuration, bool $expectedHidden)
if ($scheduledVisibilityService->shouldBeVisible($content) && $handler->isHidden($content)) {
$handler->reveal($content);
}
$content = $this->getRepository()->getContentService()->loadContent($content->getContentInfo()->getId());
$content = $this->getRepository()->getContentService()->loadContent($content->contentInfo->id);

$objectStateService = $this->getRepository()->getObjectStateService();
$objectStateGroup = $objectStateService->loadObjectStateGroup(2);
$objectState = $this->getRepository()->sudo(
static fn (): \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState => $objectStateService->getContentState($content->getContentInfo(), $objectStateGroup),
static fn (): ObjectStateValue => $objectStateService->getContentState($content->contentInfo, $objectStateGroup),
);
self::assertEquals($objectState->id, $expectedHidden ? $hiddenObjectState->id : $visibleObjectStateId);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/bundle/Integration/SectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function testUpdateVisibility(array $configuration, bool $expectedHidden)
if ($scheduledVisibilityService->shouldBeVisible($content) && $handler->isHidden($content)) {
$handler->reveal($content);
}
$content = $this->getRepository()->getContentService()->loadContent($content->getContentInfo()->getId());
self::assertEquals($content->getContentInfo()->sectionId, $expectedHidden ? $hiddenSection->id : $visibleSectionId);
$content = $this->getRepository()->getContentService()->loadContent($content->contentInfo->id);
self::assertEquals($content->contentInfo->sectionId, $expectedHidden ? $hiddenSection->id : $visibleSectionId);
}

private function getSectionHandler(int $hiddenSectionId, int $visibleSectionId): Section
Expand Down

0 comments on commit 823dd0d

Please sign in to comment.