Robert Vogel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/375736 )
Change subject: BS3: Added new Data infrastructure
......................................................................
BS3: Added new Data infrastructure
Change-Id: I0d9c9afa4e71d1ff7e7d457a7085a2b57d472eab
---
A src/Data/DatabaseReader.php
A src/Data/DatabaseWriter.php
A src/Data/IReader.php
A src/Data/IStore.php
A src/Data/IWriter.php
A src/Data/ResultSet.php
6 files changed, 118 insertions(+), 0 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation
refs/changes/36/375736/1
diff --git a/src/Data/DatabaseReader.php b/src/Data/DatabaseReader.php
new file mode 100644
index 0000000..82a2d51
--- /dev/null
+++ b/src/Data/DatabaseReader.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace BlueSpice;
+
+abstract class DatabaseReader implements BlueSpice\Data\IReader {
+
+ /**
+ *
+ * @var \DatabaseBase
+ */
+ protected $db = null;
+
+ /**
+ *
+ * @param \LoadBalancer $loadBalancer
+ */
+ public function __construct( $loadBalancer ) {
+ $this->db = $loadBalancer->getConnection( DB_REPLICA );
+ }
+}
diff --git a/src/Data/DatabaseWriter.php b/src/Data/DatabaseWriter.php
new file mode 100644
index 0000000..e0b632e
--- /dev/null
+++ b/src/Data/DatabaseWriter.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace BlueSpice;
+
+abstract class DatabaseWriter implements BlueSpice\Data\IWriter {
+
+ /**
+ *
+ * @var \DatabaseBase
+ */
+ protected $db = null;
+
+ /**
+ *
+ * @param \LoadBalancer $loadBalancer
+ */
+ public function __construct( $loadBalancer ) {
+ $this->db = $loadBalancer->getConnection( DB_MASTER );
+ }
+}
diff --git a/src/Data/IReader.php b/src/Data/IReader.php
new file mode 100644
index 0000000..f321a26
--- /dev/null
+++ b/src/Data/IReader.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace BlueSpice\Data;
+
+interface IReader {
+
+ /**
+ *
+ * @param ReaderParams $params
+ * @return ResultSet
+ */
+ public function read( $params );
+}
\ No newline at end of file
diff --git a/src/Data/IStore.php b/src/Data/IStore.php
new file mode 100644
index 0000000..addb054
--- /dev/null
+++ b/src/Data/IStore.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace BlueSpice\Data;
+
+interface IStore {
+
+ /**
+ * @return IWriter
+ */
+ public function getWriter();
+
+ /**
+ * @return IReader
+ */
+ public function getReader();
+}
\ No newline at end of file
diff --git a/src/Data/IWriter.php b/src/Data/IWriter.php
new file mode 100644
index 0000000..5668374
--- /dev/null
+++ b/src/Data/IWriter.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace BlueSpice\Data;
+
+interface IWriter {
+
+ /**
+ *
+ * @param array $dataSet
+ * @return \Status
+ */
+ public function write( $dataSet );
+}
\ No newline at end of file
diff --git a/src/Data/ResultSet.php b/src/Data/ResultSet.php
new file mode 100644
index 0000000..c7e371e
--- /dev/null
+++ b/src/Data/ResultSet.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace BlueSpice\Data;
+
+class ResultSet {
+
+ /**
+ *
+ * @var \stdClass[]
+ */
+ protected $records = [];
+
+ /**
+ *
+ * @var int
+ */
+ protected $total = 0;
+
+ /**
+ *
+ * @param \stdClass[] $records
+ * @param int $total
+ */
+ public function __construct( $records, $total ) {
+ $this->records = $records;
+ $this->total = $total;
+ }
+
+ public function getRecords() {
+ return $this->records;
+ }
+
+ public function getTotal() {
+ return $this->total;
+ }
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/375736
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d9c9afa4e71d1ff7e7d457a7085a2b57d472eab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits