diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/SPARQLStore/ReplicationDataTruncator.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/src/SPARQLStore/ReplicationDataTruncator.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/SPARQLStore/ReplicationDataTruncator.php b/www/wiki/extensions/SemanticMediaWiki/src/SPARQLStore/ReplicationDataTruncator.php new file mode 100644 index 00000000..a6d6d97c --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/src/SPARQLStore/ReplicationDataTruncator.php @@ -0,0 +1,52 @@ +<?php + +namespace SMW\SPARQLStore; + +use SMW\DIProperty; +use SMW\SemanticData; + +/** + * Truncate a SemanticData instance for the replication process + * + * @license GNU GPL v2+ + * @since 2.5 + * + * @author mwjames + */ +class ReplicationDataTruncator { + + /** + * @var array + */ + private $propertyExemptionList = []; + + /** + * @since 2.5 + * + * @param array $propertyExemptionList + */ + public function setPropertyExemptionList( array $propertyExemptionList ) { + $this->propertyExemptionList = str_replace( ' ', '_', $propertyExemptionList ); + } + + /** + * @since 2.5 + * + * @param SemanticData $semanticDat + * + * @return SemanticData + */ + public function doTruncate( SemanticData $semanticData ) { + + if ( $this->propertyExemptionList === [] ) { + return $semanticData; + } + + foreach ( $this->propertyExemptionList as $property ) { + $semanticData->removeProperty( DIProperty::newFromUserLabel( $property ) ); + } + + return $semanticData; + } + +} |