Skip to content

Commit 22da30e

Browse files
committed
IBX-6554: Refactored location and content property accessors for better consistency and null safety
1 parent 0f595d0 commit 22da30e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/bundle/Controller/ContentViewController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@ public function __construct(
160160
public function locationViewAction(Request $request, ContentView $view): ContentView
161161
{
162162
$location = $view->getLocation();
163-
if ($location === null || $location->id === null) {
164-
$contentId = $view->getContent()->id ?? 'unknown';
163+
if ($location === null || $location->getId() === null) {
164+
$contentId = $view->getContent()->getId() ?? 'unknown';
165165
throw new NotFoundException('Location', "content ID {$contentId}");
166166
}
167167

168168
// We should not cache ContentView because we use forms with CSRF tokens in template
169169
// JIRA ref: https://issues.ibexa.co/browse/EZP-28190
170170
$view->setCacheEnabled(false);
171171

172-
if (!$view->getContent()->contentInfo->isTrashed()) {
172+
if (!$view->getContent()->getContentInfo()->isTrashed()) {
173173
$this->supplyPathLocations($view);
174174
$this->subitemsContentViewParameterSupplier->supply($view);
175175
$this->supplyContentActionForms($view);

src/lib/Menu/Voter/LocationVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function matchItem(ItemInterface $item): ?bool
3737
if ($contentView instanceof ContentView) {
3838
$location = $contentView->getLocation();
3939
if ($location !== null) {
40-
$path = $location->path ?? [$location->id];
40+
$path = $location->getPath() ?? [$location->getId()];
4141

4242
if (in_array($locationId, $path, true)) {
4343
return true;

0 commit comments

Comments
 (0)