EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/168546
Change subject: Hygiene: remove dead code in BaseUrlGenerator
......................................................................
Hygiene: remove dead code in BaseUrlGenerator
With the conversion to the new url generation scheme complete the
only thing BaseUrlGenerator was doing anymore was holding the array
of loaded workflows.
This patch moves the BaseUrlGenerator::resolveTitle and
BaseUrlGenerator::withWorkflow to UrlGenerator and removes
BaseUrlGenerator.
Change-Id: I88b9ac49ab5fc2214592cc666370a32ad835d3b0
---
M autoload.php
D includes/BaseUrlGenerator.php
M includes/UrlGenerator.php
3 files changed, 45 insertions(+), 90 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/46/168546/1
diff --git a/autoload.php b/autoload.php
index c08f181..ee22c1a 100644
--- a/autoload.php
+++ b/autoload.php
@@ -44,7 +44,6 @@
$wgAutoloadClasses['Flow\\Actions\\ViewAction'] = __DIR__ .
'/includes/Actions/ViewAction.php';
$wgAutoloadClasses['Flow\\Actions\\ViewHeaderAction'] = __DIR__ .
'/includes/Actions/ViewHeaderAction.php';
$wgAutoloadClasses['Flow\\Actions\\ViewTopicSummaryAction'] = __DIR__ .
'/includes/Actions/ViewTopicSummaryAction.php';
-$wgAutoloadClasses['Flow\\BaseUrlGenerator'] = __DIR__ .
'/includes/BaseUrlGenerator.php';
$wgAutoloadClasses['Flow\\BlockFactory'] = __DIR__ .
'/includes/BlockFactory.php';
$wgAutoloadClasses['Flow\\Block\\AbstractBlock'] = __DIR__ .
'/includes/Block/Block.php';
$wgAutoloadClasses['Flow\\Block\\Block'] = __DIR__ .
'/includes/Block/Block.php';
diff --git a/includes/BaseUrlGenerator.php b/includes/BaseUrlGenerator.php
deleted file mode 100644
index d2e5af4..0000000
--- a/includes/BaseUrlGenerator.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-namespace Flow;
-
-use Flow\Data\ObjectManager;
-use Flow\Model\UUID;
-use Flow\Model\Workflow;
-use Flow\Exception\InvalidDataException;
-use Flow\Exception\InvalidInputException;
-use Flow\Exception\FlowException;
-use Title;
-
-/**
- * BaseUrlGenerator contains the logic for putting together the bits of url
- * data, without generating any specific urls.
- */
-abstract class BaseUrlGenerator {
- /**
- * @var OccupationController
- */
- protected $occupationController;
-
- /**
- * @var ObjectManager Workflow storage
- */
- protected $storage;
-
- /**
- * @var Workflow[] Cached array of already loaded workflows
- */
- protected $workflows = array();
-
- /**
- * @param OccupationController $occupationController
- */
- public function __construct( OccupationController $occupationController
) {
- $this->occupationController = $occupationController;
- }
-
- /**
- * @param Workflow $workflow
- */
- public function withWorkflow( Workflow $workflow ) {
- $this->workflows[$workflow->getId()->getAlphadecimal()] =
$workflow;
- }
-
- /**
- * @param Workflow|UUID $workflow
- * @return Workflow
- * @throws InvalidDataException
- * @throws InvalidInputException
- */
- protected function resolveWorkflow( $workflow ) {
- if ( $workflow instanceof UUID ) {
- $alpha = $workflow->getAlphadecimal();
- if ( !isset( $this->workflows[$alpha] ) ) {
- throw new InvalidInputException( 'Unloaded
workflow: ' . $alpha , 'invalid-workflow' );
- }
- $workflow = $this->workflows[$alpha];
- } elseif ( !$workflow instanceof Workflow ) {
- // otherwise calling a method on $workflow will fatal
error
- throw new InvalidDataException( '$workflow is not UUID
or Workflow instance' );
- }
- return $workflow;
- }
-
- /**
- * @param Title|null $title
- * @param UUID|null $workflowId
- * @return Title
- * @throws FlowException
- */
- protected function resolveTitle( Title $title = null, UUID $workflowId
= null ) {
- if ( $title !== null ) {
- return $title;
- }
- if ( $workflowId === null ) {
- throw new FlowException( 'No title or workflow given' );
- }
-
- $alpha = $workflowId->getAlphadecimal();
- if ( !isset( $this->workflows[$alpha] ) ) {
- throw new InvalidInputException( 'Unloaded workflow:' .
$alpha, 'invalid-workflow' );
- }
-
- return $this->workflows[$alpha]->getArticleTitle();
- }
-}
diff --git a/includes/UrlGenerator.php b/includes/UrlGenerator.php
index 4ad4f25..7e1a305 100644
--- a/includes/UrlGenerator.php
+++ b/includes/UrlGenerator.php
@@ -2,6 +2,7 @@
namespace Flow;
+use Flow\Exception\InvalidInputException;
use Flow\Exception\FlowException;
use Flow\Model\AbstractRevision;
use Flow\Model\Anchor;
@@ -9,10 +10,53 @@
use Flow\Model\PostRevision;
use Flow\Model\PostSummary;
use Flow\Model\UUID;
+use Flow\Model\Workflow;
use SpecialPage;
use Title;
-class UrlGenerator extends BaseUrlGenerator {
+/**
+ * Provides url generation capabilities for Flow. Ties together an
+ * i18n message with a specific Title, query parameters and fragment.
+ *
+ * URL generation methods mostly accept either a Title or a UUID
+ * representing the Workflow. URL generation methods all return
+ * Anchor instances..
+ */
+class UrlGenerator {
+ /**
+ * @var Workflow[] Map from alphadecimal workflow id to Workflow
instance
+ */
+ protected $workflows = array();
+
+ /**
+ * @param Workflow $workflow
+ */
+ public function withWorkflow( Workflow $workflow ) {
+ $this->workflows[$workflow->getId()->getAlphadecimal()] =
$workflow;
+ }
+
+ /**
+ * @param Title|null $title
+ * @param UUID|null $workflowId
+ * @return Title
+ * @throws FlowException
+ */
+ protected function resolveTitle( Title $title = null, UUID $workflowId
= null ) {
+ if ( $title !== null ) {
+ return $title;
+ }
+ if ( $workflowId === null ) {
+ throw new FlowException( 'No title or workflow given' );
+ }
+
+ $alpha = $workflowId->getAlphadecimal();
+ if ( !isset( $this->workflows[$alpha] ) ) {
+ throw new InvalidInputException( 'Unloaded workflow:' .
$alpha, 'invalid-workflow' );
+ }
+
+ return $this->workflows[$alpha]->getArticleTitle();
+ }
+
/**
* Link to create new topic on a topiclist.
*
--
To view, visit https://gerrit.wikimedia.org/r/168546
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I88b9ac49ab5fc2214592cc666370a32ad835d3b0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits