r91443 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91442‎ | r91443 | r91444 >
Date:07:18, 5 July 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
+method to allow immutable semantic data containers to copy data from other SMWSemanticData objects
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Container.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Container.php
@@ -59,6 +59,26 @@
6060 }
6161
6262 /**
 63+ * Change the object to become an exact copy of the given
 64+ * SMWSemanticData object. Useful to convert arbitrary such
 65+ * objects into SMWContainerSemanticData objects.
 66+ *
 67+ * @param $semanticData SMWSemanticData
 68+ */
 69+ public function copyDataFrom( SMWSemanticData $semanticData ) {
 70+ $this->throwImmutableException();
 71+ $this->mSubject = $semanticData->getSubject();
 72+ $this->mProperties = $semanticData->getProperties();
 73+ $this->mPropVals = array();
 74+ foreach ( $this->mProperties as $property ) {
 75+ $this->mPropVals[$property->getKey()] = $semanticData->getPropertyValues( $property );
 76+ }
 77+ $this->mHasVisibleProps = $semanticData->hasVisibleProperties();
 78+ $this->mHasVisibleSpecs = $semanticData->hasVisibleSpecialProperties();
 79+ $this->mNoDuplicates = $semanticData->mNoDuplicates;
 80+ }
 81+
 82+ /**
6383 * Store a value for a property identified by its SMWDataItem object,
6484 * if the object was not set to immutable.
6585 *
@@ -146,6 +166,20 @@
147167 }
148168
149169 /**
 170+ * Get an internal object that can be used as a subject for this data.
 171+ * This subject is not part of the data itself but makes the connection
 172+ * to the wiki page for which this data will be stored. This allows to
 173+ * encode a kind of provenance information when storing container data,
 174+ * useful to find the source of the data, and to retrieve more data when
 175+ * a structural (helper) node is found in a query etc.
 176+ *
 177+ * @return SMWDIWikiPage
 178+ */
 179+ public function getSubjectPage( SMWDIWikiPage $masterPage ) {
 180+ return new SMWDIWikiPage( $masterPage->getDBkey(), $masterPage->getNamespace(), $masterPage->getInterwiki(), $this->getHash() );
 181+ }
 182+
 183+ /**
150184 * Create a data item from the provided serialization string and type
151185 * ID.
152186 * @return SMWDIContainer