From d2f0ee2fa5ec94dd810fbc6f6ebe9619f7f5b3db Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 8 Mar 2024 22:21:52 +0100 Subject: [PATCH] Replaced usage of magic getters affecting subtree loading performance --- .../InContextTranslationListener.php | 2 +- src/lib/Siteaccess/SiteaccessResolver.php | 2 +- .../Strategy/ContentTypeThumbnailStrategy.php | 2 +- src/lib/UI/Module/ContentTree/NodeFactory.php | 28 +++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lib/EventListener/InContextTranslationListener.php b/src/lib/EventListener/InContextTranslationListener.php index fcc17bc13f..a894da239a 100644 --- a/src/lib/EventListener/InContextTranslationListener.php +++ b/src/lib/EventListener/InContextTranslationListener.php @@ -59,7 +59,7 @@ public function setInContextTranslation(RequestEvent $event): void return; } - $inContextSetting = $this->userSettingService->getUserSetting('in_context_translation')->value; + $inContextSetting = $this->userSettingService->getUserSetting('in_context_translation')->getValue(); if ($inContextSetting !== InContextTranslation::ENABLED_OPTION) { return; diff --git a/src/lib/Siteaccess/SiteaccessResolver.php b/src/lib/Siteaccess/SiteaccessResolver.php index cefa3f312f..6df66b2bf5 100644 --- a/src/lib/Siteaccess/SiteaccessResolver.php +++ b/src/lib/Siteaccess/SiteaccessResolver.php @@ -81,7 +81,7 @@ public function getSiteAccessesListForLocation( ): array { $contentInfo = $location->getContentInfo(); $versionInfo = $this->contentService->loadVersionInfo($contentInfo, $versionNo); - $languageCode = $languageCode ?? $contentInfo->mainLanguageCode; + $languageCode = $languageCode ?? $contentInfo->getMainLanguageCode(); $eligibleSiteAccesses = []; /** @var \Ibexa\Core\MVC\Symfony\SiteAccess $siteAccess */ diff --git a/src/lib/Strategy/ContentTypeThumbnailStrategy.php b/src/lib/Strategy/ContentTypeThumbnailStrategy.php index dca897a4c7..8973379174 100644 --- a/src/lib/Strategy/ContentTypeThumbnailStrategy.php +++ b/src/lib/Strategy/ContentTypeThumbnailStrategy.php @@ -34,7 +34,7 @@ public function getThumbnail( ?VersionInfo $versionInfo = null ): ?Thumbnail { try { - $contentTypeIcon = $this->contentTypeIconResolver->getContentTypeIcon($contentType->identifier); + $contentTypeIcon = $this->contentTypeIconResolver->getContentTypeIcon($contentType->getIdentifier()); return new Thumbnail([ 'resource' => $contentTypeIcon, diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 8764381e98..26dcd4ea2e 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -151,7 +151,7 @@ private function findSubitems( ?string $sortClause = null, string $sortOrder = Query::SORT_ASC ): SearchResult { - $searchQuery = $this->getSearchQuery($parentLocation->id); + $searchQuery = $this->getSearchQuery($parentLocation->getId()); $searchQuery->limit = $limit; $searchQuery->offset = $offset; @@ -328,17 +328,17 @@ private function buildNode( array $bookmarkLocations = [] ): Node { $contentInfo = $location->getContentInfo(); - $contentId = $location->contentId; + $contentId = $location->getContentId(); if (!isset($uninitializedContentInfoList[$contentId])) { $uninitializedContentInfoList[$contentId] = $contentInfo; } // Top Level Location (id = 1) does not have a content type - $contentType = $location->depth > 0 + $contentType = $location->getDepth() > 0 ? $contentInfo->getContentType() : null; - if ($contentType !== null && $contentType->isContainer) { + if ($contentType !== null && $contentType->isContainer()) { $containerLocations[] = $location; } @@ -359,7 +359,7 @@ private function buildNode( /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $childLocation */ foreach (array_column($searchResult->searchHits, 'valueObject') as $childLocation) { $childLoadSubtreeRequestNode = null !== $loadSubtreeRequestNode - ? $this->findChild($childLocation->id, $loadSubtreeRequestNode) + ? $this->findChild($childLocation->getId(), $loadSubtreeRequestNode) : null; $children[] = $this->buildNode( @@ -376,7 +376,7 @@ private function buildNode( } } - $translations = $versionInfo->languageCodes; + $translations = $versionInfo->getLanguageCodes(); $previewableTranslations = array_filter( $translations, fn (string $languageCode): bool => $this->isPreviewable($location, $content, $languageCode) @@ -384,19 +384,19 @@ private function buildNode( return new Node( $depth, - $location->id, - $location->contentId, - $versionInfo->versionNo, + $location->getId(), + $location->getContentId(), + $versionInfo->getVersionNo(), $translations, $previewableTranslations, '', // node name will be provided later by `supplyTranslatedContentName` method - $contentType ? $contentType->identifier : '', - $contentType ? $contentType->isContainer : true, - $location->invisible || $location->hidden, + null !== $contentType ? $contentType->getIdentifier() : '', + !(null !== $contentType) || $contentType->isContainer(), + $location->isInvisible() || $location->isHidden(), $limit, $totalChildrenCount, $this->getReverseRelationsCount($contentInfo), - isset($bookmarkLocations[$location->id]), + isset($bookmarkLocations[$location->getId()]), $children, $location->getPathString() ); @@ -455,7 +455,7 @@ private function isPreviewable( Content $content, string $languageCode ): bool { - $versionNo = $content->getVersionInfo()->versionNo; + $versionNo = $content->getVersionInfo()->getVersionNo(); $siteAccesses = $this->siteaccessResolver->getSiteAccessesListForLocation( $location,