mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 10:22:42 +01:00
aa7ba4c6e6
Summary: Ref T3886. Now that a custom field can emit a core transaction, just emit a subscribers transaction. Test Plan: {F116014} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3886 Differential Revision: https://secure.phabricator.com/D8289
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class DifferentialEditPolicyField
|
|
extends DifferentialCoreCustomField {
|
|
|
|
public function getFieldKey() {
|
|
return 'differential:edit-policy';
|
|
}
|
|
|
|
public function getFieldName() {
|
|
return pht('Edit Policy');
|
|
}
|
|
|
|
public function getFieldDescription() {
|
|
return pht('Controls who can edit a revision.');
|
|
}
|
|
|
|
protected function readValueFromRevision(
|
|
DifferentialRevision $revision) {
|
|
return $revision->getEditPolicy();
|
|
}
|
|
|
|
public function readValueFromRequest(AphrontRequest $request) {
|
|
$this->setValue($request->getStr($this->getFieldKey()));
|
|
}
|
|
|
|
public function renderEditControl(array $handles) {
|
|
$viewer = $this->getViewer();
|
|
$revision = $this->getObject();
|
|
|
|
$policies = id(new PhabricatorPolicyQuery())
|
|
->setViewer($viewer)
|
|
->setObject($revision)
|
|
->execute();
|
|
|
|
return id(new AphrontFormPolicyControl())
|
|
->setUser($viewer)
|
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
|
->setPolicyObject($revision)
|
|
->setPolicies($policies)
|
|
->setName($this->getFieldKey())
|
|
->setValue($this->getValue())
|
|
->setError($this->getFieldError());
|
|
}
|
|
|
|
public function getApplicationTransactionType() {
|
|
return PhabricatorTransactions::TYPE_EDIT_POLICY;
|
|
}
|
|
|
|
}
|