1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Modularize all remaining Pholio Herald fields

Summary: Ref T8726. Use modular fields for the Pholio adapter.

Test Plan:
  - Created rule using all the old fields.
  - Migrated, saw upgrade apply correctly.
  - Created mock, reviewed transcript.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: eadler, epriestley

Maniphest Tasks: T8726

Differential Revision: https://secure.phabricator.com/D13513
This commit is contained in:
epriestley 2015-07-06 13:17:33 -07:00
parent 83c0fda280
commit 415e4d4cc1
8 changed files with 120 additions and 40 deletions

View file

@ -0,0 +1,20 @@
UPDATE {$NAMESPACE}_herald.herald_condition c
JOIN {$NAMESPACE}_herald.herald_rule r
ON c.ruleID = r.id
SET c.fieldName = 'pholio.mock.name'
WHERE r.contentType = 'HeraldPholioMockAdapter'
AND c.fieldName = 'title';
UPDATE {$NAMESPACE}_herald.herald_condition c
JOIN {$NAMESPACE}_herald.herald_rule r
ON c.ruleID = r.id
SET c.fieldName = 'pholio.mock.description'
WHERE r.contentType = 'HeraldPholioMockAdapter'
AND c.fieldName = 'body';
UPDATE {$NAMESPACE}_herald.herald_condition c
JOIN {$NAMESPACE}_herald.herald_rule r
ON c.ruleID = r.id
SET c.fieldName = 'pholio.mock.author'
WHERE r.contentType = 'HeraldPholioMockAdapter'
AND c.fieldName = 'author';

View file

@ -954,7 +954,7 @@ phutil_register_library_map(array(
'HeraldNewController' => 'applications/herald/controller/HeraldNewController.php',
'HeraldNewObjectField' => 'applications/herald/field/HeraldNewObjectField.php',
'HeraldObjectTranscript' => 'applications/herald/storage/transcript/HeraldObjectTranscript.php',
'HeraldPholioMockAdapter' => 'applications/herald/adapter/HeraldPholioMockAdapter.php',
'HeraldPholioMockAdapter' => 'applications/pholio/herald/HeraldPholioMockAdapter.php',
'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php',
'HeraldPreCommitContentAdapter' => 'applications/diffusion/herald/HeraldPreCommitContentAdapter.php',
'HeraldPreCommitRefAdapter' => 'applications/diffusion/herald/HeraldPreCommitRefAdapter.php',
@ -2969,14 +2969,18 @@ phutil_register_library_map(array(
'PholioInlineController' => 'applications/pholio/controller/PholioInlineController.php',
'PholioInlineListController' => 'applications/pholio/controller/PholioInlineListController.php',
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
'PholioMockAuthorHeraldField' => 'applications/pholio/herald/PholioMockAuthorHeraldField.php',
'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php',
'PholioMockDescriptionHeraldField' => 'applications/pholio/herald/PholioMockDescriptionHeraldField.php',
'PholioMockEditController' => 'applications/pholio/controller/PholioMockEditController.php',
'PholioMockEditor' => 'applications/pholio/editor/PholioMockEditor.php',
'PholioMockEmbedView' => 'applications/pholio/view/PholioMockEmbedView.php',
'PholioMockHasTaskEdgeType' => 'applications/pholio/edge/PholioMockHasTaskEdgeType.php',
'PholioMockHeraldField' => 'applications/pholio/herald/PholioMockHeraldField.php',
'PholioMockImagesView' => 'applications/pholio/view/PholioMockImagesView.php',
'PholioMockListController' => 'applications/pholio/controller/PholioMockListController.php',
'PholioMockMailReceiver' => 'applications/pholio/mail/PholioMockMailReceiver.php',
'PholioMockNameHeraldField' => 'applications/pholio/herald/PholioMockNameHeraldField.php',
'PholioMockPHIDType' => 'applications/pholio/phid/PholioMockPHIDType.php',
'PholioMockQuery' => 'applications/pholio/query/PholioMockQuery.php',
'PholioMockSearchEngine' => 'applications/pholio/query/PholioMockSearchEngine.php',
@ -6841,14 +6845,18 @@ phutil_register_library_map(array(
'PhabricatorSpacesInterface',
'PhabricatorMentionableInterface',
),
'PholioMockAuthorHeraldField' => 'PholioMockHeraldField',
'PholioMockCommentController' => 'PholioController',
'PholioMockDescriptionHeraldField' => 'PholioMockHeraldField',
'PholioMockEditController' => 'PholioController',
'PholioMockEditor' => 'PhabricatorApplicationTransactionEditor',
'PholioMockEmbedView' => 'AphrontView',
'PholioMockHasTaskEdgeType' => 'PhabricatorEdgeType',
'PholioMockHeraldField' => 'HeraldField',
'PholioMockImagesView' => 'AphrontView',
'PholioMockListController' => 'PholioController',
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',
'PholioMockNameHeraldField' => 'PholioMockHeraldField',
'PholioMockPHIDType' => 'PhabricatorPHIDType',
'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine',

View file

@ -186,7 +186,16 @@ abstract class HeraldAdapter extends Phobject {
throw new Exception(pht("Unknown field '%s'!", $field_name));
}
abstract public function applyHeraldEffects(array $effects);
public function applyHeraldEffects(array $effects) {
assert_instances_of($effects, 'HeraldEffect');
$result = array();
foreach ($effects as $effect) {
$result[] = $this->applyStandardEffect($effect);
}
return $result;
}
protected function handleCustomHeraldEffect(HeraldEffect $effect) {
$custom_action = idx($this->getCustomActions(), $effect->getAction());

View file

@ -47,16 +47,6 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
}
}
public function getFields() {
return array_merge(
array(
self::FIELD_TITLE,
self::FIELD_BODY,
self::FIELD_AUTHOR,
),
parent::getFields());
}
public function getActions($rule_type) {
switch ($rule_type) {
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
@ -87,32 +77,4 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
return 'M'.$this->getMock()->getID();
}
public function getHeraldField($field) {
switch ($field) {
case self::FIELD_TITLE:
return $this->getMock()->getName();
case self::FIELD_BODY:
return $this->getMock()->getDescription();
case self::FIELD_AUTHOR:
return $this->getMock()->getAuthorPHID();
}
return parent::getHeraldField($field);
}
public function applyHeraldEffects(array $effects) {
assert_instances_of($effects, 'HeraldEffect');
$result = array();
foreach ($effects as $effect) {
$action = $effect->getAction();
switch ($action) {
default:
$result[] = $this->applyStandardEffect($effect);
break;
}
}
return $result;
}
}

View file

@ -0,0 +1,24 @@
<?php
final class PholioMockAuthorHeraldField
extends PholioMockHeraldField {
const FIELDCONST = 'pholio.mock.author';
public function getHeraldFieldName() {
return pht('Author');
}
public function getHeraldFieldValue($object) {
return $object->getAuthorPHID();
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_PHID;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_USER;
}
}

View file

@ -0,0 +1,24 @@
<?php
final class PholioMockDescriptionHeraldField
extends PholioMockHeraldField {
const FIELDCONST = 'pholio.mock.description';
public function getHeraldFieldName() {
return pht('Description');
}
public function getHeraldFieldValue($object) {
return $object->getDescription();
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_TEXT;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
}

View file

@ -0,0 +1,9 @@
<?php
abstract class PholioMockHeraldField extends HeraldField {
public function supportsObject($object) {
return ($object instanceof PholioMock);
}
}

View file

@ -0,0 +1,24 @@
<?php
final class PholioMockNameHeraldField
extends PholioMockHeraldField {
const FIELDCONST = 'pholio.mock.name';
public function getHeraldFieldName() {
return pht('Name');
}
public function getHeraldFieldValue($object) {
return $object->getName();
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_TEXT;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
}