mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-20 10:48:40 +01:00
Summary: Ref T9964. Three goals here: - Make it easier to supply Conduit documentation. - Make automatic documentation for `*.edit` endpoints more complete, particularly for custom fields. - Allow type resolution via Conduit types, so you can pass `["alincoln"]` to "subscribers" instead of needing to use PHIDs. Test Plan: - Viewed and used all search and edit endpoints, including custom fields. - Used parameter type resolution to set subscribers to user "dog" instead of "PHID-USER-whatever". - Viewed HTTP parameter documentation. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9964 Differential Revision: https://secure.phabricator.com/D14796
63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
final class PhabricatorPolicyEditField
|
|
extends PhabricatorEditField {
|
|
|
|
private $policies;
|
|
private $capability;
|
|
private $spaceField;
|
|
|
|
public function setPolicies(array $policies) {
|
|
$this->policies = $policies;
|
|
return $this;
|
|
}
|
|
|
|
public function getPolicies() {
|
|
if ($this->policies === null) {
|
|
throw new PhutilInvalidStateException('setPolicies');
|
|
}
|
|
return $this->policies;
|
|
}
|
|
|
|
public function setCapability($capability) {
|
|
$this->capability = $capability;
|
|
return $this;
|
|
}
|
|
|
|
public function getCapability() {
|
|
return $this->capability;
|
|
}
|
|
|
|
public function setSpaceField(PhabricatorSpaceEditField $space_field) {
|
|
$this->spaceField = $space_field;
|
|
return $this;
|
|
}
|
|
|
|
public function getSpaceField() {
|
|
return $this->spaceField;
|
|
}
|
|
|
|
protected function newControl() {
|
|
$control = id(new AphrontFormPolicyControl())
|
|
->setCapability($this->getCapability())
|
|
->setPolicyObject($this->getObject())
|
|
->setPolicies($this->getPolicies());
|
|
|
|
$space_field = $this->getSpaceField();
|
|
if ($space_field) {
|
|
$control->setSpacePHID($space_field->getValueForControl());
|
|
}
|
|
|
|
return $control;
|
|
}
|
|
|
|
protected function newHTTPParameterType() {
|
|
return new AphrontPHIDHTTPParameterType();
|
|
}
|
|
|
|
protected function newConduitParameterType() {
|
|
return new ConduitStringParameterType();
|
|
}
|
|
|
|
|
|
}
|