Changeset View
Changeset View
Standalone View
Standalone View
src/applications/audit/storage/PhabricatorAuditComment.php
<?php | <?php | ||||
final class PhabricatorAuditComment | final class PhabricatorAuditComment | ||||
implements PhabricatorMarkupInterface { | implements PhabricatorMarkupInterface { | ||||
const METADATA_ADDED_AUDITORS = 'added-auditors'; | |||||
const MARKUP_FIELD_BODY = 'markup:body'; | const MARKUP_FIELD_BODY = 'markup:body'; | ||||
private $proxyComment; | private $proxyComment; | ||||
private $proxy; | private $proxy; | ||||
public function __construct() { | public function __construct() { | ||||
$this->proxy = new PhabricatorAuditTransaction(); | $this->proxy = new PhabricatorAuditTransaction(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS: | case PhabricatorTransactions::TYPE_SUBSCRIBERS: | ||||
case PhabricatorAuditActionConstants::ADD_AUDITORS: | case PhabricatorAuditActionConstants::ADD_AUDITORS: | ||||
return $type; | return $type; | ||||
default: | default: | ||||
return $this->proxy->getNewValue(); | return $this->proxy->getNewValue(); | ||||
} | } | ||||
} | } | ||||
public function setMetadata(array $metadata) { | |||||
if (!$this->proxy->getTransactionType()) { | |||||
throw new Exception(pht('Call setAction() before getMetadata()!')); | |||||
} | |||||
$type = $this->proxy->getTransactionType(); | |||||
switch ($type) { | |||||
case PhabricatorAuditActionConstants::ADD_AUDITORS: | |||||
$raw_phids = idx($metadata, self::METADATA_ADDED_AUDITORS, array()); | |||||
break; | |||||
default: | |||||
throw new Exception(pht('No metadata expected!')); | |||||
} | |||||
$this->proxy->setNewValue(array_fuse($raw_phids)); | |||||
return $this; | |||||
} | |||||
public function getMetadata() { | |||||
if (!$this->proxy->getTransactionType()) { | |||||
throw new Exception(pht('Call setAction() before getMetadata()!')); | |||||
} | |||||
$type = $this->proxy->getTransactionType(); | |||||
$new_value = $this->proxy->getNewValue(); | |||||
switch ($type) { | |||||
case PhabricatorAuditActionConstants::ADD_AUDITORS: | |||||
return array( | |||||
self::METADATA_ADDED_AUDITORS => array_keys($new_value), | |||||
); | |||||
} | |||||
return array(); | |||||
} | |||||
public function save() { | public function save() { | ||||
throw new Exception( | throw new Exception( | ||||
pht('This object can no longer be written to directly!')); | pht('This object can no longer be written to directly!')); | ||||
} | } | ||||
public function getTransactionForSave() { | public function getTransactionForSave() { | ||||
$xaction = $this->proxy; | $xaction = $this->proxy; | ||||
if (strlen($this->getContent())) { | if (strlen($this->getContent())) { | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |