for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SESP\PropertyAnnotators;
use SMW\DIProperty;
use SMW\SemanticData;
use SMWDataItem as DataItem;
use SMWDINumber as DINumber;
use SESP\PropertyAnnotator;
use SESP\AppFactory;
/**
* @private
* @ingroup SESP
*
* @license GNU GPL v2+
* @since 2.0
* @author mwjames
*/
class PageNumRevisionPropertyAnnotator implements PropertyAnnotator {
* Predefined property ID
const PROP_ID = '___NREV';
* @var AppFactory
private $appFactory;
* @param AppFactory $appFactory
public function __construct( AppFactory $appFactory ) {
$this->appFactory = $appFactory;
}
* {@inheritDoc}
public function isAnnotatorFor( DIProperty $property ) {
return $property->getKey() === self::PROP_ID;
public function addAnnotation( DIProperty $property, SemanticData $semanticData ) {
$title = $semanticData->getSubject()->getTitle();
$numRevisions = $this->getPageRevisions(
$title->getArticleID()
);
$dataItem = null;
if ( $title->exists() && $numRevisions > 0 ) {
$dataItem = new DINumber( $numRevisions );
if ( $dataItem instanceof DataItem ) {
$semanticData->addPropertyObjectValue( $property, $dataItem );
private function getPageRevisions( $pageId ) {
return $this->appFactory->getConnection()->estimateRowCount(
"revision",
"*",
[ "rev_page" => $pageId ]