The current implementation already accesses the revisions content to retrieve the categories, but it does add it to the context.
|
private function buildContext( RevisionRecord $revision, ?UserIdentity $user ): PagePropertyProviderContext { |
|
$linkTarget = $revision->getPageAsLinkTarget(); |
|
|
|
return new PagePropertyProviderContext( |
|
pageId: new PageId( $revision->getPageId() ), |
|
pageTitle: $this->titleFormatter->getPrefixedText( $linkTarget ), |
|
namespaceId: $linkTarget->getNamespace(), |
|
creationTime: $this->getCreationTime( $revision ), |
|
modificationTime: $this->getModificationTime( $revision ), |
|
categories: $this->getCategories( $revision ), |
|
lastEditor: $user?->getName() ?? '', |
|
); |
|
} |
|
private function getCategories( RevisionRecord $revision ): array { |
|
$content = $revision->getContent( SlotRecord::MAIN ); |
|
|
|
if ( $content === null ) { |
|
return []; |
|
} |
|
|
|
return $this->contentHandlerFactory->getContentHandler( $content->getModel() ) |
|
->getParserOutput( $content, new ContentParseParams( $revision->getPage() ) ) |
|
->getCategoryNames(); |
|
} |
A PagePropertyProvider that wants to analyze the content would need to perform additional steps to retrieve it from the context.
I believe it would be useful for future extension developers to provide the actual content of the revision to PagePropertyProvider implementations via the context. It would ease generating page properties based on other things in the content ("@-mentions", "task list items", ...).
The current implementation already accesses the revisions content to retrieve the categories, but it does add it to the context.
NeoWiki/src/PagePropertiesBuilder.php
Lines 41 to 53 in d1f7341
NeoWiki/src/PagePropertiesBuilder.php
Lines 78 to 88 in d1f7341
A
PagePropertyProviderthat wants to analyze the content would need to perform additional steps to retrieve it from the context.I believe it would be useful for future extension developers to provide the actual content of the revision to
PagePropertyProviderimplementations via the context. It would ease generating page properties based on other things in the content ("@-mentions", "task list items", ...).