Skip to content

Commit

Permalink
Replaced usage of magic getters affecting subtree loading performance
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Mar 14, 2024
1 parent 7ed8eb2 commit d2f0ee2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/lib/EventListener/InContextTranslationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Siteaccess/SiteaccessResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Strategy/ContentTypeThumbnailStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions src/lib/UI/Module/ContentTree/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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(
Expand All @@ -376,27 +376,27 @@ private function buildNode(
}
}

$translations = $versionInfo->languageCodes;
$translations = $versionInfo->getLanguageCodes();
$previewableTranslations = array_filter(
$translations,
fn (string $languageCode): bool => $this->isPreviewable($location, $content, $languageCode)
);

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()
);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d2f0ee2

Please sign in to comment.