3 final class PhabricatorMetaMTAApplicationEmail
4 extends PhabricatorMetaMTADAO
6 PhabricatorPolicyInterface
,
7 PhabricatorApplicationTransactionInterface
,
8 PhabricatorDestructibleInterface
,
9 PhabricatorSpacesInterface
{
11 protected $applicationPHID;
13 protected $configData;
16 private $application = self
::ATTACHABLE
;
18 const CONFIG_DEFAULT_AUTHOR
= 'config:default:author';
20 protected function getConfiguration() {
22 self
::CONFIG_AUX_PHID
=> true,
23 self
::CONFIG_SERIALIZATION
=> array(
24 'configData' => self
::SERIALIZATION_JSON
,
26 self
::CONFIG_COLUMN_SCHEMA
=> array(
27 'address' => 'sort128',
29 self
::CONFIG_KEY_SCHEMA
=> array(
30 'key_address' => array(
31 'columns' => array('address'),
34 'key_application' => array(
35 'columns' => array('applicationPHID'),
38 ) + parent
::getConfiguration();
41 public function generatePHID() {
42 return PhabricatorPHID
::generateNewPHID(
43 PhabricatorMetaMTAApplicationEmailPHIDType
::TYPECONST
);
46 public static function initializeNewAppEmail(PhabricatorUser
$actor) {
47 return id(new PhabricatorMetaMTAApplicationEmail())
48 ->setSpacePHID($actor->getDefaultSpacePHID())
49 ->setConfigData(array());
52 public function attachApplication(PhabricatorApplication
$app) {
53 $this->application
= $app;
57 public function getApplication() {
58 return self
::assertAttached($this->application
);
61 public function setConfigValue($key, $value) {
62 $this->configData
[$key] = $value;
66 public function getConfigValue($key, $default = null) {
67 return idx($this->configData
, $key, $default);
70 public function getDefaultAuthorPHID() {
71 return $this->getConfigValue(self
::CONFIG_DEFAULT_AUTHOR
);
74 public function getInUseMessage() {
75 $applications = PhabricatorApplication
::getAllApplications();
76 $applications = mpull($applications, null, 'getPHID');
79 $this->getApplicationPHID());
82 'The address %s is configured to be used by the %s Application.',
84 $application->getName());
87 'The address %s is configured to be used by an application.',
94 public function newAddress() {
95 return new PhutilEmailAddress($this->getAddress());
98 /* -( PhabricatorPolicyInterface )----------------------------------------- */
101 public function getCapabilities() {
103 PhabricatorPolicyCapability
::CAN_VIEW
,
104 PhabricatorPolicyCapability
::CAN_EDIT
,
108 public function getPolicy($capability) {
109 return $this->getApplication()->getPolicy($capability);
112 public function hasAutomaticCapability(
114 PhabricatorUser
$viewer) {
116 return $this->getApplication()->hasAutomaticCapability(
121 public function describeAutomaticCapability($capability) {
122 return $this->getApplication()->describeAutomaticCapability($capability);
126 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
129 public function getApplicationTransactionEditor() {
130 return new PhabricatorMetaMTAApplicationEmailEditor();
133 public function getApplicationTransactionTemplate() {
134 return new PhabricatorMetaMTAApplicationEmailTransaction();
138 /* -( PhabricatorDestructibleInterface )----------------------------------- */
141 public function destroyObjectPermanently(
142 PhabricatorDestructionEngine
$engine) {
147 /* -( PhabricatorSpacesInterface )----------------------------------------- */
150 public function getSpacePHID() {
151 return $this->spacePHID
;