Skip to content

Provide revision content to PagePropertyProviderContext #979

Description

@osnard

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", ...).

Metadata

Metadata

Assignees

Labels

BlueSpiceCapabilities specific to, or particularly relevant for, BlueSpiceextendabilityPlugin points

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions