Pwirth has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/381184 )
Change subject: Using the data store to determinate the fields, that need to be saved ...................................................................... Using the data store to determinate the fields, that need to be saved Change-Id: I725c90fb402cb6d46b0a917370ef492299cf05de --- A src/Data/Entity/Writer.php M src/Entity.php M src/EntityConfig.php 3 files changed, 49 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation refs/changes/84/381184/1 diff --git a/src/Data/Entity/Writer.php b/src/Data/Entity/Writer.php new file mode 100644 index 0000000..bc56dc3 --- /dev/null +++ b/src/Data/Entity/Writer.php @@ -0,0 +1,36 @@ +<?php + +namespace BlueSpice\Data\Entity; + +abstract class Writer implements \BlueSpice\Data\IWriter { + + /** + * + * @var \IContextSource + */ + protected $context = null; + + public function __construct( \IContextSource $context = null, \Config $config = null ) { + $this->context = $context; + if( $this->context === null ) { + $this->context = \RequestContext::getMain(); + } + $this->config = $config; + if( $this->config === null ) { + $this->config = \MediaWiki\MediaWikiServices::getInstance()->getMainConfig(); + } + } + + public function getSchema() { + return new Schema(); + } + + /** + * + * @param array $dataSet + * @return \Status + */ + public function write( $dataSet ) { + throw new Exception( 'Writing entity store is not supported yet' ); + } +} \ No newline at end of file diff --git a/src/Entity.php b/src/Entity.php index 275097a..9857921 100644 --- a/src/Entity.php +++ b/src/Entity.php @@ -241,11 +241,22 @@ if ( is_null( $oTitle ) ) { return \Status::newFatal( 'Related Title error' ); } + $sStoreClass = $this->getConfig()->get( 'StoreClass' ); + if( !class_exists( $sStoreClass ) ) { + return \Status::newFatal( "Store class '$sStoreClass' not found" ); + } + $oStore = new $sStoreClass( \RequestContext::getMain() ); + $oSchema = $oStore->getWriter()->getSchema(); + $aData = array_intersect_key( + $this->getFullData(), + array_flip( $oSchema->getStorableFields() ) + ); $oWikiPage = \WikiPage::factory( $oTitle ); + try { $oStatus = $oWikiPage->doEditContent( - new $sContentClass( json_encode( $this ) ), + new $sContentClass( json_encode( $aData ) ), "", 0, 0, diff --git a/src/EntityConfig.php b/src/EntityConfig.php index 5018097..6f5c783 100644 --- a/src/EntityConfig.php +++ b/src/EntityConfig.php @@ -116,6 +116,7 @@ abstract protected function addGetterDefaults(); abstract protected function get_EntityClass(); + abstract protected function get_StoreClass(); protected function get_ContentClass() { return "\\BlueSpice\\Content\\Entity"; -- To view, visit https://gerrit.wikimedia.org/r/381184 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I725c90fb402cb6d46b0a917370ef492299cf05de Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation Gerrit-Branch: master Gerrit-Owner: Pwirth <wi...@hallowelt.biz> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits