1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Modularize all remaining Phriction Herald fields

Summary: Ref T8726.

Test Plan:
  - Created a rule using all the fields.
  - Updated documents, saw rule apply, reviewed transcript.
  - Migrated stuff.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: eadler, epriestley

Maniphest Tasks: T8726

Differential Revision: https://secure.phabricator.com/D13514
This commit is contained in:
epriestley 2015-07-06 13:17:50 -07:00
parent 415e4d4cc1
commit 68de3dae9a
11 changed files with 139 additions and 52 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 = 'phriction.document.title'
WHERE r.contentType = 'PhrictionDocumentHeraldAdapter'
AND c.fieldName = 'title';
UPDATE {$NAMESPACE}_herald.herald_condition c
JOIN {$NAMESPACE}_herald.herald_rule r
ON c.ruleID = r.id
SET c.fieldName = 'phriction.document.content'
WHERE r.contentType = 'PhrictionDocumentHeraldAdapter'
AND c.fieldName = 'body';
UPDATE {$NAMESPACE}_herald.herald_condition c
JOIN {$NAMESPACE}_herald.herald_rule r
ON c.ruleID = r.id
SET c.fieldName = 'phriction.document.author'
WHERE r.contentType = 'PhrictionDocumentHeraldAdapter'
AND c.fieldName = 'author';

View file

@ -3159,11 +3159,16 @@ phutil_register_library_map(array(
'PhrictionDeleteController' => 'applications/phriction/controller/PhrictionDeleteController.php',
'PhrictionDiffController' => 'applications/phriction/controller/PhrictionDiffController.php',
'PhrictionDocument' => 'applications/phriction/storage/PhrictionDocument.php',
'PhrictionDocumentAuthorHeraldField' => 'applications/phriction/herald/PhrictionDocumentAuthorHeraldField.php',
'PhrictionDocumentContentHeraldField' => 'applications/phriction/herald/PhrictionDocumentContentHeraldField.php',
'PhrictionDocumentController' => 'applications/phriction/controller/PhrictionDocumentController.php',
'PhrictionDocumentHeraldAdapter' => 'applications/phriction/herald/PhrictionDocumentHeraldAdapter.php',
'PhrictionDocumentHeraldField' => 'applications/phriction/herald/PhrictionDocumentHeraldField.php',
'PhrictionDocumentPHIDType' => 'applications/phriction/phid/PhrictionDocumentPHIDType.php',
'PhrictionDocumentPathHeraldField' => 'applications/phriction/herald/PhrictionDocumentPathHeraldField.php',
'PhrictionDocumentQuery' => 'applications/phriction/query/PhrictionDocumentQuery.php',
'PhrictionDocumentStatus' => 'applications/phriction/constants/PhrictionDocumentStatus.php',
'PhrictionDocumentTitleHeraldField' => 'applications/phriction/herald/PhrictionDocumentTitleHeraldField.php',
'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php',
'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php',
'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php',
@ -7090,11 +7095,16 @@ phutil_register_library_map(array(
'PhabricatorDestructibleInterface',
'PhabricatorApplicationTransactionInterface',
),
'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentController' => 'PhrictionController',
'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter',
'PhrictionDocumentHeraldField' => 'HeraldField',
'PhrictionDocumentPHIDType' => 'PhabricatorPHIDType',
'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhrictionDocumentStatus' => 'PhrictionConstants',
'PhrictionDocumentTitleHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod',
'PhrictionEditController' => 'PhrictionController',
'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod',

View file

@ -29,7 +29,6 @@ abstract class HeraldAdapter extends Phobject {
const FIELD_AUTHOR_RAW = 'author-raw';
const FIELD_COMMITTER_RAW = 'committer-raw';
const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer';
const FIELD_PATH = 'path';
const CONDITION_CONTAINS = 'contains';
const CONDITION_NOT_CONTAINS = '!contains';
@ -174,7 +173,10 @@ abstract class HeraldAdapter extends Phobject {
return $this->applicationEmail;
}
abstract public function getPHID();
public function getPHID() {
return $this->getObject()->getPHID();
}
abstract public function getHeraldName();
public function getHeraldField($field_name) {
@ -389,7 +391,6 @@ abstract class HeraldAdapter extends Phobject {
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'),
self::FIELD_PATH => pht('Path'),
);
}
@ -436,7 +437,6 @@ abstract class HeraldAdapter extends Phobject {
case self::FIELD_BODY:
case self::FIELD_COMMITTER_RAW:
case self::FIELD_AUTHOR_RAW:
case self::FIELD_PATH:
return array(
self::CONDITION_CONTAINS,
self::CONDITION_NOT_CONTAINS,

View file

@ -93,10 +93,6 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
}
}
public function getPHID() {
return $this->getTask()->getPHID();
}
public function getHeraldName() {
return 'T'.$this->getTask()->getID();
}

View file

@ -69,10 +69,6 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
}
}
public function getPHID() {
return $this->getMock()->getPHID();
}
public function getHeraldName() {
return 'M'.$this->getMock()->getID();
}

View file

@ -0,0 +1,24 @@
<?php
final class PhrictionDocumentAuthorHeraldField
extends PhrictionDocumentHeraldField {
const FIELDCONST = 'phriction.document.author';
public function getHeraldFieldName() {
return pht('Author');
}
public function getHeraldFieldValue($object) {
return $object->getContent()->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 PhrictionDocumentContentHeraldField
extends PhrictionDocumentHeraldField {
const FIELDCONST = 'phriction.document.content';
public function getHeraldFieldName() {
return pht('Content');
}
public function getHeraldFieldValue($object) {
return $object->getContent()->getContent();
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_TEXT;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
}

View file

@ -48,17 +48,6 @@ final class PhrictionDocumentHeraldAdapter extends HeraldAdapter {
}
}
public function getFields() {
return array_merge(
array(
self::FIELD_TITLE,
self::FIELD_BODY,
self::FIELD_AUTHOR,
self::FIELD_PATH,
),
parent::getFields());
}
public function getActions($rule_type) {
switch ($rule_type) {
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
@ -83,38 +72,9 @@ final class PhrictionDocumentHeraldAdapter extends HeraldAdapter {
}
}
public function getPHID() {
return $this->getDocument()->getPHID();
}
public function getHeraldName() {
return pht('Wiki Document %d', $this->getDocument()->getID());
}
public function getHeraldField($field) {
switch ($field) {
case self::FIELD_TITLE:
return $this->getDocument()->getContent()->getTitle();
case self::FIELD_BODY:
return $this->getDocument()->getContent()->getContent();
case self::FIELD_AUTHOR:
return $this->getDocument()->getContent()->getAuthorPHID();
case self::FIELD_PATH:
return $this->getDocument()->getContent()->getSlug();
}
return parent::getHeraldField($field);
}
public function applyHeraldEffects(array $effects) {
assert_instances_of($effects, 'HeraldEffect');
$result = array();
foreach ($effects as $effect) {
$result[] = $this->applyStandardEffect($effect);
}
return $result;
}
}

View file

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

View file

@ -0,0 +1,24 @@
<?php
final class PhrictionDocumentPathHeraldField
extends PhrictionDocumentHeraldField {
const FIELDCONST = 'path';
public function getHeraldFieldName() {
return pht('Path');
}
public function getHeraldFieldValue($object) {
return $object->getcontent()->getSlug();
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_TEXT;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
}

View file

@ -0,0 +1,24 @@
<?php
final class PhrictionDocumentTitleHeraldField
extends PhrictionDocumentHeraldField {
const FIELDCONST = 'phriction.document.title';
public function getHeraldFieldName() {
return pht('Title');
}
public function getHeraldFieldValue($object) {
return $object->getContent()->getTitle();
}
protected function getHeraldFieldStandardConditions() {
return self::STANDARD_TEXT;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
}