Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / metamta / storage / PhabricatorMetaMTAApplicationEmail.php
blobf5673bed9d0e5012d7d925b58c6dcda820861b6b
1 <?php
3 final class PhabricatorMetaMTAApplicationEmail
4 extends PhabricatorMetaMTADAO
5 implements
6 PhabricatorPolicyInterface,
7 PhabricatorApplicationTransactionInterface,
8 PhabricatorDestructibleInterface,
9 PhabricatorSpacesInterface {
11 protected $applicationPHID;
12 protected $address;
13 protected $configData;
14 protected $spacePHID;
16 private $application = self::ATTACHABLE;
18 const CONFIG_DEFAULT_AUTHOR = 'config:default:author';
20 protected function getConfiguration() {
21 return array(
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'),
32 'unique' => true,
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;
54 return $this;
57 public function getApplication() {
58 return self::assertAttached($this->application);
61 public function setConfigValue($key, $value) {
62 $this->configData[$key] = $value;
63 return $this;
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');
77 $application = idx(
78 $applications,
79 $this->getApplicationPHID());
80 if ($application) {
81 $message = pht(
82 'The address %s is configured to be used by the %s Application.',
83 $this->getAddress(),
84 $application->getName());
85 } else {
86 $message = pht(
87 'The address %s is configured to be used by an application.',
88 $this->getAddress());
91 return $message;
94 public function newAddress() {
95 return new PhutilEmailAddress($this->getAddress());
98 /* -( PhabricatorPolicyInterface )----------------------------------------- */
101 public function getCapabilities() {
102 return array(
103 PhabricatorPolicyCapability::CAN_VIEW,
104 PhabricatorPolicyCapability::CAN_EDIT,
108 public function getPolicy($capability) {
109 return $this->getApplication()->getPolicy($capability);
112 public function hasAutomaticCapability(
113 $capability,
114 PhabricatorUser $viewer) {
116 return $this->getApplication()->hasAutomaticCapability(
117 $capability,
118 $viewer);
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) {
143 $this->delete();
147 /* -( PhabricatorSpacesInterface )----------------------------------------- */
150 public function getSpacePHID() {
151 return $this->spacePHID;