summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/PropertyAnnotators/RedirectPropertyAnnotator.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/PropertyAnnotators/RedirectPropertyAnnotator.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/src/PropertyAnnotators/RedirectPropertyAnnotator.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/PropertyAnnotators/RedirectPropertyAnnotator.php b/www/wiki/extensions/SemanticMediaWiki/src/PropertyAnnotators/RedirectPropertyAnnotator.php
new file mode 100644
index 00000000..e06c3618
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/src/PropertyAnnotators/RedirectPropertyAnnotator.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace SMW\PropertyAnnotators;
+
+use SMW\DIProperty;
+use SMW\DIWikiPage;
+use SMW\MediaWiki\RedirectTargetFinder;
+use SMW\PropertyAnnotator;
+
+/**
+ * Handling redirect annotation
+ *
+ * @license GNU GPL v2+
+ * @since 1.9
+ *
+ * @author mwjames
+ */
+class RedirectPropertyAnnotator extends PropertyAnnotatorDecorator {
+
+ /**
+ * @var RedirectTargetFinder
+ */
+ private $redirectTargetFinder;
+
+ /**
+ * @since 1.9
+ *
+ * @param PropertyAnnotator $propertyAnnotator
+ * @param RedirectTargetFinder $redirectTargetFinder
+ */
+ public function __construct( PropertyAnnotator $propertyAnnotator, RedirectTargetFinder $redirectTargetFinder ) {
+ parent::__construct( $propertyAnnotator );
+ $this->redirectTargetFinder = $redirectTargetFinder;
+ }
+
+ /**
+ * @see PropertyAnnotatorDecorator::addPropertyValues
+ */
+ protected function addPropertyValues() {
+
+ if ( !$this->redirectTargetFinder->hasRedirectTarget() ) {
+ return;
+ }
+
+ $this->getSemanticData()->addPropertyObjectValue(
+ new DIProperty( '_REDI' ),
+ DIWikiPage::newFromTitle( $this->redirectTargetFinder->getRedirectTarget() )
+ );
+ }
+
+}