Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/contracts/Persistence/Content/Type/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function loadGroupByIdentifier($identifier);
/**
* @return \Ibexa\Contracts\Core\Persistence\Content\Type\Group[]
*/
public function loadAllGroups();
public function loadAllGroups(bool $includeSystem = false);

/**
* @param mixed $groupId
Expand Down
3 changes: 2 additions & 1 deletion src/contracts/Repository/ContentTypeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ public function loadContentTypeGroupByIdentifier(string $contentTypeGroupIdentif
* Get all content type groups.
*
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object.
* @param bool $includeSystem When true also returns system ContentTypeGroups. Default false.
*
* @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup[]
*/
public function loadContentTypeGroups(array $prioritizedLanguages = []): iterable;
public function loadContentTypeGroups(array $prioritizedLanguages = [], bool $includeSystem = false): iterable;

/**
* Update a content type group object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function loadContentTypeGroupByIdentifier(
return $this->innerService->loadContentTypeGroupByIdentifier($contentTypeGroupIdentifier, $prioritizedLanguages);
}

public function loadContentTypeGroups(array $prioritizedLanguages = []): iterable
public function loadContentTypeGroups(array $prioritizedLanguages = [], bool $includeSystem = false): iterable
{
return $this->innerService->loadContentTypeGroups($prioritizedLanguages);
return $this->innerService->loadContentTypeGroups($prioritizedLanguages, $includeSystem);
}

public function updateContentTypeGroup(
Expand Down
14 changes: 10 additions & 4 deletions src/lib/Persistence/Cache/ContentTypeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function createGroup(GroupCreateStruct $struct)
$this->logger->logCall(__METHOD__, ['struct' => $struct]);
$this->cache->deleteItems([
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [], true),
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [true], true),
]);

return $this->persistenceHandler->contentTypeHandler()->createGroup($struct);
Expand All @@ -115,6 +116,7 @@ public function updateGroup(GroupUpdateStruct $struct)

$this->cache->deleteItems([
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [], true),
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [true], true),
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [$struct->id], true),
$this->cacheIdentifierGenerator->generateKey(
self::CONTENT_TYPE_GROUP_WITH_ID_SUFFIX_IDENTIFIER,
Expand All @@ -137,6 +139,10 @@ public function deleteGroup($groupId)
$this->cache->invalidateTags([
$this->cacheIdentifierGenerator->generateTag(self::TYPE_GROUP_IDENTIFIER, [$groupId]),
]);
$this->cache->deleteItems([
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [], true),
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [true], true),
]);

return $return;
}
Expand Down Expand Up @@ -193,12 +199,12 @@ function () use ($identifier) {
/**
* {@inheritdoc}
*/
public function loadAllGroups()
public function loadAllGroups(bool $includeSystem = false)
{
return $this->getListCacheValue(
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [], true),
function () {
return $this->persistenceHandler->contentTypeHandler()->loadAllGroups();
$this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [$includeSystem], true),
function () use ($includeSystem) {
return $this->persistenceHandler->contentTypeHandler()->loadAllGroups($includeSystem);
},
$this->getGroupTags,
$this->getGroupKeys
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Persistence/Legacy/Content/Type/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract public function loadGroupData(array $groupIds): array;

abstract public function loadGroupDataByIdentifier(string $identifier): array;

abstract public function loadAllGroupsData(): array;
abstract public function loadAllGroupsData(bool $includeSystem = false): array;

/**
* Load data for all content types of the given status, belonging to the given Group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,18 @@ public function loadGroupDataByIdentifier(string $identifier): array
return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE);
}

public function loadAllGroupsData(): array
public function loadAllGroupsData(bool $includeSystem = false): array
{
$query = $this->createGroupLoadQuery();

$query->andWhere(
$query->expr()->eq(
'is_system',
$query->createPositionalParameter(false, ParameterType::BOOLEAN)
)
);
if (!$includeSystem) {
$query->andWhere(
$query->expr()->eq(
'is_system',
$query->createPositionalParameter(false, ParameterType::BOOLEAN)
)
);
}

return $query->execute()->fetchAll(FetchMode::ASSOCIATIVE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public function loadGroupDataByIdentifier(string $identifier): array
}
}

public function loadAllGroupsData(): array
public function loadAllGroupsData(bool $includeSystem = false): array
{
try {
return $this->innerGateway->loadAllGroupsData();
return $this->innerGateway->loadAllGroupsData($includeSystem);
} catch (DBALException | PDOException $e) {
throw DatabaseException::wrap($e);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Persistence/Legacy/Content/Type/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ public function loadGroupByIdentifier($identifier)
/**
* @return \Ibexa\Contracts\Core\Persistence\Content\Type\Group[]
*/
public function loadAllGroups()
public function loadAllGroups(bool $includeSystem = false)
{
return $this->mapper->extractGroupsFromRows(
$this->contentTypeGateway->loadAllGroupsData()
$this->contentTypeGateway->loadAllGroupsData($includeSystem)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function createGroup(GroupCreateStruct $createStruct): Group
$this->storeGroupCache([$group]);
$this->cache->deleteMulti([
$this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true),
$this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [true], true),
]);

return $group;
Expand All @@ -64,6 +65,7 @@ public function updateGroup(GroupUpdateStruct $struct): Group
$this->storeGroupCache([$group]);
$this->cache->deleteMulti([
$this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true),
$this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [true], true),
]);

return $group;
Expand All @@ -76,6 +78,7 @@ public function deleteGroup($groupId): void
$this->cache->deleteMulti([
$this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$groupId], true),
$this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true),
$this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [true], true),
]);
}

Expand Down Expand Up @@ -139,13 +142,13 @@ public function loadGroupByIdentifier($identifier): Group
/**
* @return \Ibexa\Contracts\Core\Persistence\Content\Type\Group[]
*/
public function loadAllGroups(): array
public function loadAllGroups(bool $includeSystem = false): array
{
$contentTypeGroupListKey = $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true);
$contentTypeGroupListKey = $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [$includeSystem], true);
$groups = $this->cache->get($contentTypeGroupListKey);

if ($groups === null) {
$groups = $this->innerHandler->loadAllGroups();
$groups = $this->innerHandler->loadAllGroups($includeSystem);
$this->storeGroupCache($groups, $contentTypeGroupListKey);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/Repository/ContentTypeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ public function loadContentTypeGroupByIdentifier(string $contentTypeGroupIdentif
/**
* {@inheritdoc}
*/
public function loadContentTypeGroups(array $prioritizedLanguages = []): iterable
public function loadContentTypeGroups(array $prioritizedLanguages = [], bool $includeSystem = false): iterable
{
$spiGroups = $this->contentTypeHandler->loadAllGroups();
$spiGroups = $this->contentTypeHandler->loadAllGroups($includeSystem);

$groups = [];
foreach ($spiGroups as $spiGroup) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Repository/SiteAccessAware/ContentTypeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public function loadContentTypeGroupByIdentifier(string $contentTypeGroupIdentif
return $this->service->loadContentTypeGroupByIdentifier($contentTypeGroupIdentifier, $prioritizedLanguages);
}

public function loadContentTypeGroups(?array $prioritizedLanguages = null): iterable
public function loadContentTypeGroups(?array $prioritizedLanguages = null, bool $includeSystem = false): iterable
{
$prioritizedLanguages = $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);

return $this->service->loadContentTypeGroups($prioritizedLanguages);
return $this->service->loadContentTypeGroups($prioritizedLanguages, $includeSystem);
}

public function updateContentTypeGroup(ContentTypeGroup $contentTypeGroup, ContentTypeGroupUpdateStruct $contentTypeGroupUpdateStruct): void
Expand Down
Loading
Loading