diff --git a/resources/sql/autopatches/20150701.herald.2.sql b/resources/sql/autopatches/20150701.herald.2.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150701.herald.2.sql @@ -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'; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3159,11 +3159,16 @@ '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 @@ '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', diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -29,7 +29,6 @@ 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 @@ 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 @@ 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 @@ 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, diff --git a/src/applications/maniphest/herald/HeraldManiphestTaskAdapter.php b/src/applications/maniphest/herald/HeraldManiphestTaskAdapter.php --- a/src/applications/maniphest/herald/HeraldManiphestTaskAdapter.php +++ b/src/applications/maniphest/herald/HeraldManiphestTaskAdapter.php @@ -93,10 +93,6 @@ } } - public function getPHID() { - return $this->getTask()->getPHID(); - } - public function getHeraldName() { return 'T'.$this->getTask()->getID(); } diff --git a/src/applications/pholio/herald/HeraldPholioMockAdapter.php b/src/applications/pholio/herald/HeraldPholioMockAdapter.php --- a/src/applications/pholio/herald/HeraldPholioMockAdapter.php +++ b/src/applications/pholio/herald/HeraldPholioMockAdapter.php @@ -69,10 +69,6 @@ } } - public function getPHID() { - return $this->getMock()->getPHID(); - } - public function getHeraldName() { return 'M'.$this->getMock()->getID(); } diff --git a/src/applications/phriction/herald/PhrictionDocumentAuthorHeraldField.php b/src/applications/phriction/herald/PhrictionDocumentAuthorHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/herald/PhrictionDocumentAuthorHeraldField.php @@ -0,0 +1,24 @@ +getContent()->getAuthorPHID(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_PHID; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_USER; + } + +} diff --git a/src/applications/phriction/herald/PhrictionDocumentContentHeraldField.php b/src/applications/phriction/herald/PhrictionDocumentContentHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/herald/PhrictionDocumentContentHeraldField.php @@ -0,0 +1,24 @@ +getContent()->getContent(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_TEXT; + } + +} diff --git a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php --- a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php +++ b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php @@ -48,17 +48,6 @@ } } - 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 @@ } } - 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; - } - } diff --git a/src/applications/phriction/herald/PhrictionDocumentHeraldField.php b/src/applications/phriction/herald/PhrictionDocumentHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/herald/PhrictionDocumentHeraldField.php @@ -0,0 +1,9 @@ +getcontent()->getSlug(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_TEXT; + } + +} diff --git a/src/applications/phriction/herald/PhrictionDocumentTitleHeraldField.php b/src/applications/phriction/herald/PhrictionDocumentTitleHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/herald/PhrictionDocumentTitleHeraldField.php @@ -0,0 +1,24 @@ +getContent()->getTitle(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_TEXT; + } + +}