[MediaWiki-commits] [Gerrit] Rework and drop unused code from EditEntityAction - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Rework and drop unused code from EditEntityAction .. Rework and drop unused code from EditEntityAction Change-Id: Iea535aeb6be88311ff66eca149967f11fde1be35 --- M repo/includes/actions/EditEntityAction.php 1 file changed, 81 insertions(+), 116 deletions(-) Approvals: Hoo man: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/actions/EditEntityAction.php b/repo/includes/actions/EditEntityAction.php index 479a07b..c613acc 100644 --- a/repo/includes/actions/EditEntityAction.php +++ b/repo/includes/actions/EditEntityAction.php @@ -39,57 +39,50 @@ abstract class EditEntityAction extends ViewEntityAction { /** -* @var EntityIdLabelFormatter -*/ - protected $propertyNameFormatter; - - /** -* @var SnakFormatter -*/ - protected $detailedSnakFormatter; - - /** -* @var SnakFormatter -*/ - protected $terseSnakFormatter; - - /** * @var EntityDiffVisualizer */ - protected $diffVisualizer; + private $entityDiffVisualizer; + /** +* @param Page $page +* @param IContextSource|null $context +*/ public function __construct( Page $page, IContextSource $context = null ) { parent::__construct( $page, $context ); - $langCode = $this->getContext()->getLanguage()->getCode(); + $languageCode = $this->getContext()->getLanguage()->getCode(); //TODO: proper injection $options = new FormatterOptions( array( //TODO: fallback chain - ValueFormatter::OPT_LANG => $langCode + ValueFormatter::OPT_LANG => $languageCode ) ); $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $termLookup = new EntityRetrievingTermLookup( $wikibaseRepo->getEntityLookup() ); - $labelLookup = new LanguageLabelLookup( $termLookup, $langCode ); + $labelLookup = new LanguageLabelLookup( $termLookup, $languageCode ); $labelFormatter = new EntityIdLabelFormatter( $options, $labelLookup ); - $this->propertyNameFormatter = new EscapingValueFormatter( $labelFormatter, 'htmlspecialchars' ); + $propertyIdFormatter = new EscapingValueFormatter( $labelFormatter, 'htmlspecialchars' ); $formatterFactory = $wikibaseRepo->getSnakFormatterFactory(); - $this->detailedSnakFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML_DIFF, $options ); - $this->terseSnakFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML, $options ); + $snakDetailsFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML_DIFF, $options ); + $snakBreadCrumbFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML, $options ); - $this->diffVisualizer = new EntityDiffVisualizer( + $this->entityDiffVisualizer = new EntityDiffVisualizer( $this->getContext(), new ClaimDiffer( new OrderedListDiffer( new ComparableComparer() ) ), - new ClaimDifferenceVisualizer( $this->propertyNameFormatter, $this->detailedSnakFormatter, $this->terseSnakFormatter, $langCode ), + new ClaimDifferenceVisualizer( + $propertyIdFormatter, + $snakDetailsFormatter, + $snakBreadCrumbFormatter, + $languageCode + ), $wikibaseRepo->getSiteStore(), $wikibaseRepo->getEntityTitleLookup(), $wikibaseRepo->getEntityRevisionLookup() ); - } /** @@ -108,13 +101,12 @@ * * @since 0.1 * -* @param String $action the action to check +* @param string $action The action to check * * @return bool true if there were permission errors */ - public function showPermissionError( $action ) { + protected function showPermissionError( $action ) { if ( !$this->getTitle()->userCan( $action, $this->getUser() ) ) { - $this->getOutput()->showPermissionsErrorPage( array( $this->getTitle()->getUserPermissionsErrors( $action, $this->getUser() ) ), $action @@ -135,7 +127,7 @@ * @return Status a Status object containing an array with three revisions, ($olderRevision, $newerRevision, $latestRevision) * @throws MWException if the page's lates
[MediaWiki-commits] [Gerrit] Rework and drop unused code from EditEntityAction - change (mediawiki...Wikibase)
Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/174836 Change subject: Rework and drop unused code from EditEntityAction .. Rework and drop unused code from EditEntityAction Change-Id: Iea535aeb6be88311ff66eca149967f11fde1be35 --- M repo/includes/actions/EditEntityAction.php 1 file changed, 81 insertions(+), 116 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/36/174836/1 diff --git a/repo/includes/actions/EditEntityAction.php b/repo/includes/actions/EditEntityAction.php index 479a07b..c613acc 100644 --- a/repo/includes/actions/EditEntityAction.php +++ b/repo/includes/actions/EditEntityAction.php @@ -39,57 +39,50 @@ abstract class EditEntityAction extends ViewEntityAction { /** -* @var EntityIdLabelFormatter -*/ - protected $propertyNameFormatter; - - /** -* @var SnakFormatter -*/ - protected $detailedSnakFormatter; - - /** -* @var SnakFormatter -*/ - protected $terseSnakFormatter; - - /** * @var EntityDiffVisualizer */ - protected $diffVisualizer; + private $entityDiffVisualizer; + /** +* @param Page $page +* @param IContextSource|null $context +*/ public function __construct( Page $page, IContextSource $context = null ) { parent::__construct( $page, $context ); - $langCode = $this->getContext()->getLanguage()->getCode(); + $languageCode = $this->getContext()->getLanguage()->getCode(); //TODO: proper injection $options = new FormatterOptions( array( //TODO: fallback chain - ValueFormatter::OPT_LANG => $langCode + ValueFormatter::OPT_LANG => $languageCode ) ); $wikibaseRepo = WikibaseRepo::getDefaultInstance(); $termLookup = new EntityRetrievingTermLookup( $wikibaseRepo->getEntityLookup() ); - $labelLookup = new LanguageLabelLookup( $termLookup, $langCode ); + $labelLookup = new LanguageLabelLookup( $termLookup, $languageCode ); $labelFormatter = new EntityIdLabelFormatter( $options, $labelLookup ); - $this->propertyNameFormatter = new EscapingValueFormatter( $labelFormatter, 'htmlspecialchars' ); + $propertyIdFormatter = new EscapingValueFormatter( $labelFormatter, 'htmlspecialchars' ); $formatterFactory = $wikibaseRepo->getSnakFormatterFactory(); - $this->detailedSnakFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML_DIFF, $options ); - $this->terseSnakFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML, $options ); + $snakDetailsFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML_DIFF, $options ); + $snakBreadCrumbFormatter = $formatterFactory->getSnakFormatter( SnakFormatter::FORMAT_HTML, $options ); - $this->diffVisualizer = new EntityDiffVisualizer( + $this->entityDiffVisualizer = new EntityDiffVisualizer( $this->getContext(), new ClaimDiffer( new OrderedListDiffer( new ComparableComparer() ) ), - new ClaimDifferenceVisualizer( $this->propertyNameFormatter, $this->detailedSnakFormatter, $this->terseSnakFormatter, $langCode ), + new ClaimDifferenceVisualizer( + $propertyIdFormatter, + $snakDetailsFormatter, + $snakBreadCrumbFormatter, + $languageCode + ), $wikibaseRepo->getSiteStore(), $wikibaseRepo->getEntityTitleLookup(), $wikibaseRepo->getEntityRevisionLookup() ); - } /** @@ -108,13 +101,12 @@ * * @since 0.1 * -* @param String $action the action to check +* @param string $action The action to check * * @return bool true if there were permission errors */ - public function showPermissionError( $action ) { + protected function showPermissionError( $action ) { if ( !$this->getTitle()->userCan( $action, $this->getUser() ) ) { - $this->getOutput()->showPermissionsErrorPage( array( $this->getTitle()->getUserPermissionsErrors( $action, $this->getUser() ) ), $action @@ -135,7 +127,7 @@ * @return Status a Status object containing an array with three revisions, ($olderRevision, $newerRevision,