summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/SourceProfileAnnotator.php
blob: 31837010a99923f8b7fb0f13e7dbca7a6d7c12ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace SMW\Query\ProfileAnnotators;

use SMW\DIProperty;
use SMW\Query\ProfileAnnotator;
use SMWDIBlob as DIBlob;

/**
 * @license GNU GPL v2+
 * @since 2.5
 *
 * @author mwjames
 */
class SourceProfileAnnotator extends ProfileAnnotatorDecorator {

	/**
	 * @var string
	 */
	private $querySource;

	/**
	 * @since 2.5
	 *
	 * @param ProfileAnnotator $profileAnnotator
	 * @param string $querySource
	 */
	public function __construct( ProfileAnnotator $profileAnnotator, $querySource = '' ) {
		parent::__construct( $profileAnnotator );
		$this->querySource = $querySource;
	}

	/**
	 * ProfileAnnotatorDecorator::addPropertyValues
	 */
	protected function addPropertyValues() {
		if ( $this->querySource !== '' ) {
			$this->addQuerySource( $this->querySource );
		}
	}

	private function addQuerySource( $querySource ) {
		$this->getSemanticData()->addPropertyObjectValue(
			new DIProperty( '_ASKSC' ),
			new DIBlob( $querySource )
		);
	}

}