1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-13 18:32:41 +01:00
phorge-phorge/src/applications/differential/storage/DifferentialComment.php
epriestley 32dd8af9e5 Reduce surface area of DifferentialComment API
Summary:
Ref T2222. Shrink the API to make it easier to move this object's storage to ApplicationTransactions.

Fixes T3415. This moves the "Summary" and "Test Plan" into the property list, and thereby fixes all the attribution problems associated with commandeering, creating a revision from another user's diff, etc.

Test Plan: Browsed several revisions.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3415, T2222

Differential Revision: https://secure.phabricator.com/D7375
2013-10-21 17:01:27 -07:00

96 lines
2.3 KiB
PHP

<?php
final class DifferentialComment extends DifferentialDAO
implements PhabricatorMarkupInterface {
const METADATA_ADDED_REVIEWERS = 'added-reviewers';
const METADATA_REMOVED_REVIEWERS = 'removed-reviewers';
const METADATA_ADDED_CCS = 'added-ccs';
const METADATA_DIFF_ID = 'diff-id';
const MARKUP_FIELD_BODY = 'markup:body';
protected $authorPHID;
protected $revisionID;
protected $action;
protected $content;
protected $cache;
protected $metadata = array();
protected $contentSource;
private $arbitraryDiffForFacebook;
public function setRevision(DifferentialRevision $revision) {
return $this->setRevisionID($revision->getID());
}
public function giveFacebookSomeArbitraryDiff(DifferentialDiff $diff) {
$this->arbitraryDiffForFacebook = $diff;
return $this;
}
public function getRequiredHandlePHIDs() {
$phids = array();
$metadata = $this->getMetadata();
$added_reviewers = idx(
$metadata,
self::METADATA_ADDED_REVIEWERS);
if ($added_reviewers) {
foreach ($added_reviewers as $phid) {
$phids[] = $phid;
}
}
$added_ccs = idx(
$metadata,
self::METADATA_ADDED_CCS);
if ($added_ccs) {
foreach ($added_ccs as $phid) {
$phids[] = $phid;
}
}
return $phids;
}
public function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(
'metadata' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration();
}
public function setContentSource(PhabricatorContentSource $content_source) {
$this->contentSource = $content_source->serialize();
return $this;
}
public function getContentSource() {
return PhabricatorContentSource::newFromSerialized($this->contentSource);
}
public function getMarkupFieldKey($field) {
return 'DC:'.$this->getID();
}
public function newMarkupEngine($field) {
return PhabricatorMarkupEngine::newDifferentialMarkupEngine(
array(
'differential.diff' => $this->arbitraryDiffForFacebook,
));
}
public function getMarkupText($field) {
return $this->getContent();
}
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
return $output;
}
public function shouldUseMarkupCache($field) {
return (bool)$this->getID();
}
}