Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/218685
Change subject: Add an easy way to get from *Revision to board Workflow
......................................................................
Add an easy way to get from *Revision to board Workflow
Change-Id: I5374286d72817a2ced20d7172c19ce22e8eb4ec1
---
M includes/Collection/AbstractCollection.php
M includes/Collection/HeaderCollection.php
M includes/Collection/PostCollection.php
M includes/Collection/PostSummaryCollection.php
4 files changed, 39 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/85/218685/1
diff --git a/includes/Collection/AbstractCollection.php
b/includes/Collection/AbstractCollection.php
index 320af64..f69b32a 100644
--- a/includes/Collection/AbstractCollection.php
+++ b/includes/Collection/AbstractCollection.php
@@ -47,6 +47,13 @@
abstract public function getWorkflowId();
/**
+ * Returns the id of the workflow of the board this collection is on.
+ *
+ * @return UUID
+ */
+ abstract public function getBoardWorkflowId();
+
+ /**
* Use the static methods to load an object from a given revision.
*
* @see AbstractCollection::newFromId
@@ -228,4 +235,8 @@
return $this->workflow;
}
+
+ public function getBoardWorkflow() {
+ return $this->getStorage( 'Flow\\Model\\Workflow' )->get(
$this->getBoardWorkflowId() );
+ }
}
diff --git a/includes/Collection/HeaderCollection.php
b/includes/Collection/HeaderCollection.php
index 01e2d43..3f4eefa 100644
--- a/includes/Collection/HeaderCollection.php
+++ b/includes/Collection/HeaderCollection.php
@@ -10,4 +10,8 @@
public function getWorkflowId() {
return $this->getId();
}
+
+ public function getBoardWorkflowId() {
+ return $this->getId();
+ }
}
diff --git a/includes/Collection/PostCollection.php
b/includes/Collection/PostCollection.php
index fef59ce..cd2b405 100644
--- a/includes/Collection/PostCollection.php
+++ b/includes/Collection/PostCollection.php
@@ -3,6 +3,8 @@
namespace Flow\Collection;
use Flow\Container;
+use Flow\Exception\InvalidDataException;
+use Flow\Model\TopicListEntry;
use Flow\Model\UUID;
class PostCollection extends LocalCacheAbstractCollection {
@@ -31,6 +33,24 @@
}
/**
+ * @return UUID
+ * @throws InvalidDataException
+ */
+ public function getBoardWorkflowId() {
+ $found = $this->getStorage( 'Flow\\Model\\TopicListEntry'
)->find(
+ // uses flow_topic_list:topic index, for topic->board
lookups
+ array( 'topic_id' => $this->getWorkflowId() )
+ );
+ if ( !$found) {
+ throw new InvalidDataException( 'No TopicListEntry
founds for topic id ' . $this->getWorkflowId()->getAlphadecimal(),
'invalid-workflow' );
+ }
+
+ /** @var TopicListEntry $topicListEntry */
+ $topicListEntry = $found[0];
+ return $topicListEntry->getListId();
+ }
+
+ /**
* Returns the topic title collection this post is associated with.
*
* @return PostCollection
diff --git a/includes/Collection/PostSummaryCollection.php
b/includes/Collection/PostSummaryCollection.php
index d42a869..02275c7 100644
--- a/includes/Collection/PostSummaryCollection.php
+++ b/includes/Collection/PostSummaryCollection.php
@@ -26,6 +26,10 @@
return $this->rootId;
}
+ public function getBoardWorkflowId() {
+ return $this->getPost()->getBoardWorkflowId();
+ }
+
/**
* Get the post collection for this summary
* @return PostCollection
--
To view, visit https://gerrit.wikimedia.org/r/218685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5374286d72817a2ced20d7172c19ce22e8eb4ec1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits