Changeset View
Changeset View
Standalone View
Standalone View
src/applications/release/storage/ReleaseChangeRequest.php
- This file was added.
<?php | |||||
final class ReleaseChangeRequest extends PhabricatorReleaseDAO | |||||
implements | |||||
PhabricatorApplicationTransactionInterface, | |||||
PhabricatorPolicyInterface, | |||||
PhabricatorCustomFieldInterface { | |||||
protected $requestorPHID; | |||||
protected $releasePHID; | |||||
protected $status = self::STATUS_PENDING; | |||||
protected $implementationKey; | |||||
protected $details; | |||||
// This is mostly a PHID, but might be a branch name in a repo or something. | |||||
protected $requestReference; | |||||
private $release = self::ATTACHABLE; | |||||
const STATUS_PENDING = 'pending'; | |||||
const STATUS_REJECTED = 'rejected'; | |||||
const STATUS_INCLUDED = 'included'; | |||||
public function setDescription($description) { | |||||
// TODO: Description as a built-in Custom Field ? | |||||
return $this; | |||||
} | |||||
public function getDescription() { | |||||
// TODO: Description as a built-in Custom Field ? | |||||
return 'All the good things come to an end.'; | |||||
} | |||||
public function getTitle() { | |||||
return 'burn production'; | |||||
} | |||||
public function getDetail($key, $default = null) { | |||||
return idx($this->getDetails(), $key, $default); | |||||
} | |||||
public function setDetail($key, $value) { | |||||
$this->details[$key] = $value; | |||||
return $this; | |||||
} | |||||
public function getURI() { | |||||
return '/Y'.$this->getID(); | |||||
} | |||||
public function getMonogram() { | |||||
return 'Y'.$this->getID(); | |||||
} | |||||
protected function getConfiguration() { | |||||
return array( | |||||
self::CONFIG_AUX_PHID => true, | |||||
self::CONFIG_SERIALIZATION => array( | |||||
'details' => self::SERIALIZATION_JSON, | |||||
), | |||||
self::CONFIG_COLUMN_SCHEMA => array( | |||||
'requestorPHID' => 'phid', | |||||
'releasePHID' => 'phid', | |||||
'requestReference' => 'text255', | |||||
'status' => 'text32', | |||||
'implementationKey' => 'text32', | |||||
), | |||||
self::CONFIG_KEY_SCHEMA => array( | |||||
'key_release' => array( | |||||
'columns' => array('releasePHID'), | |||||
'unique' => false, | |||||
), | |||||
), | |||||
) + parent::getConfiguration(); | |||||
} | |||||
public function getPHIDType() { | |||||
return ReleaseChangeRequestPHIDType::TYPECONST; | |||||
} | |||||
public function attachRelease(PhabricatorReleaseRelease $release) { | |||||
$this->release = $release; | |||||
return $this; | |||||
} | |||||
public function getRelease() { | |||||
return $this->assertAttached($this->release); | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | |||||
public function getApplicationTransactionEditor() { | |||||
return new ReleaseChangeRequestEditor(); | |||||
} | |||||
public function getApplicationTransactionObject() { | |||||
return $this; | |||||
} | |||||
public function getApplicationTransactionTemplate() { | |||||
return new ReleaseChangeRequestTransaction(); | |||||
} | |||||
public function willRenderTimeline( | |||||
PhabricatorApplicationTransactionView $timeline, | |||||
AphrontRequest $request) { | |||||
return $timeline; | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | |||||
return array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
); | |||||
} | |||||
public function getPolicy($capability) { | |||||
switch ($capability) { | |||||
case PhabricatorPolicyCapability::CAN_VIEW: | |||||
case PhabricatorPolicyCapability::CAN_EDIT: // TODO | |||||
return PhabricatorPolicies::POLICY_USER; | |||||
} | |||||
} | |||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
return false; | |||||
} | |||||
/* -( PhabricatorCustomFieldInterface )------------------------------------ */ | |||||
private $customFields = self::ATTACHABLE; | |||||
public function getCustomFieldSpecificationForRole($role) { | |||||
return array(); // TODO | |||||
// return PhabricatorEnv::getEnvConfig(<<<'application.fields'>>>); | |||||
} | |||||
public function getCustomFieldBaseClass() { | |||||
return 'ReleaseChangeRequestCustomField'; | |||||
} | |||||
public function getCustomFields() { | |||||
return $this->assertAttached($this->customFields); | |||||
} | |||||
public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { | |||||
$this->customFields = $fields; | |||||
return $this; | |||||
} | |||||
} |