-
Notifications
You must be signed in to change notification settings - Fork 82
5.0: Use RelationListIterator #2548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.0
Are you sure you want to change the base?
Changes from all commits
04aebc3
5bb1f2d
da094da
cfa1c89
aba03c3
540f4fe
1660c18
3ad69f9
967d0a1
ee23889
82f3b6e
d4b3637
4a7cf16
fe4b07c
6bfd8f2
5ff4dee
d025c0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,9 +28,9 @@ | |||||||||
``` php hl_lines="10" | ||||||||||
// ... | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 4, 5) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 20, 22) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 22, 24) =]] | ||||||||||
// ... | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 55, 57) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 63, 72) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 57, 59) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 65, 73) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
|
||||||||||
|
@@ -46,7 +46,7 @@ | |||||||||
To get the locations of a content item you need to make use of the [`LocationService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html): | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 73, 77) =]] } | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 75, 79) =]] } | ||||||||||
``` | ||||||||||
|
||||||||||
[`LocationService::loadLocations`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_loadLocations) uses `ContentInfo` to get all the locations of a content item. | ||||||||||
|
@@ -60,29 +60,29 @@ | |||||||||
[`URLAliasService::reverseLookup`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-URLAliasService.html#method_reverseLookup) gets the location's main [URL alias](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-URLAlias.html): | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 73, 76) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 77, 80) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 75, 78) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 79, 82) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
### Content type | ||||||||||
|
||||||||||
You can retrieve the content type of a content item through the [`getContentType`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html#method_getContentType) method of the ContentInfo object: | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 82, 84) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 84, 86) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
### Versions | ||||||||||
|
||||||||||
To iterate over the versions of a content item, use the [`ContentService::loadVersions`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadVersions) method, which returns an array of `VersionInfo` value objects. | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 86, 92) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 88, 94) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
You can additionally provide the `loadVersions` method with the version status to get only versions of a specific status, for example: | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 93, 94) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 95, 96) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
!!! note | ||||||||||
|
@@ -93,12 +93,16 @@ | |||||||||
### Relations | ||||||||||
|
||||||||||
Content Relations are versioned. | ||||||||||
To list Relations to and from your content, you need to pass a `VersionInfo` object to the [`ContentService::loadRelationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadRelationList) method. | ||||||||||
This method loads only the specified subset of relations to improve performance and was created with pagination in mind. | ||||||||||
To list Relations to and from your content, you can: | ||||||||||
|
||||||||||
- pass a `VersionInfo` object to the [`ContentService::loadRelationList` method](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadRelationList) which returns a slice of the relation list thanks to pagination arguments | ||||||||||
Check failure on line 98 in docs/content_management/content_api/browsing_content.md
|
||||||||||
- use the [`RelationListIteratorAdapter`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIteratorAdapter-RelationListIteratorAdapter.html) | ||||||||||
within a [`BatchIterator`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html) which allow traversing the relation list using one same object | ||||||||||
Check failure on line 100 in docs/content_management/content_api/browsing_content.md
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Could you please add the RelationListAdapter to the list of Adapters on https://doc.ibexa.co/en/latest/search/search_api/#processing-large-result-sets ? |
||||||||||
|
||||||||||
You can get the current version's `VersionInfo` using [`ContentService::loadVersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadVersionInfo). | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 105, 112) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 107, 118) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
You can also specify the version number as the second argument to get Relations for a specific version: | ||||||||||
|
@@ -117,7 +121,7 @@ | |||||||||
You can use the `getOwner` method of the `ContentInfo` object to load the content item's owner as a `User` value object. | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 114, 115) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 120, 121) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
To get the creator of the current version and not the content item's owner, you need to use the `creatorId` property from the current version's `VersionInfo` object. | ||||||||||
|
@@ -127,7 +131,7 @@ | |||||||||
You can find the section to which a content item belongs through the [`getSection`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html#method_getSection) method of the ContentInfo object: | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 117, 118) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 123, 124) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
!!! note | ||||||||||
|
@@ -142,7 +146,7 @@ | |||||||||
All object state groups can be retrieved through [`loadObjectStateGroups`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_loadObjectStateGroups). | ||||||||||
|
||||||||||
``` php | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 120, 125) =]] | ||||||||||
[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 126, 131) =]] | ||||||||||
``` | ||||||||||
|
||||||||||
## Viewing content with fields | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.