Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / transactions / engineextension / PhabricatorApplicationObjectMailEngineExtension.php
blobbf441df71c1128c1507cef231487891dcbc8f4cb
1 <?php
3 final class PhabricatorApplicationObjectMailEngineExtension
4 extends PhabricatorMailEngineExtension {
6 const EXTENSIONKEY = 'application/object';
8 public function supportsObject($object) {
9 return true;
12 public function newMailStampTemplates($object) {
13 $templates = array(
14 id(new PhabricatorStringMailStamp())
15 ->setKey('application')
16 ->setLabel(pht('Application')),
19 if ($this->hasMonogram($object)) {
20 $templates[] = id(new PhabricatorStringMailStamp())
21 ->setKey('monogram')
22 ->setLabel(pht('Object Monogram'));
25 if ($this->hasPHID($object)) {
26 // This is a PHID, but we always want to render it as a raw string, so
27 // use a string mail stamp.
28 $templates[] = id(new PhabricatorStringMailStamp())
29 ->setKey('phid')
30 ->setLabel(pht('Object PHID'));
32 $templates[] = id(new PhabricatorStringMailStamp())
33 ->setKey('object-type')
34 ->setLabel(pht('Object Type'));
37 return $templates;
40 public function newMailStamps($object, array $xactions) {
41 $editor = $this->getEditor();
42 $viewer = $this->getViewer();
44 $application = null;
45 $class = $editor->getEditorApplicationClass();
46 if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
47 $application = newv($class, array());
50 if ($application) {
51 $application_name = $application->getName();
52 $this->getMailStamp('application')
53 ->setValue($application_name);
56 if ($this->hasMonogram($object)) {
57 $monogram = $object->getMonogram();
58 $this->getMailStamp('monogram')
59 ->setValue($monogram);
62 if ($this->hasPHID($object)) {
63 $object_phid = $object->getPHID();
65 $this->getMailStamp('phid')
66 ->setValue($object_phid);
68 $phid_type = phid_get_type($object_phid);
69 if ($phid_type != PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
70 $this->getMailStamp('object-type')
71 ->setValue($phid_type);
76 private function hasPHID($object) {
77 if (!($object instanceof LiskDAO)) {
78 return false;
81 if (!$object->getConfigOption(LiskDAO::CONFIG_AUX_PHID)) {
82 return false;
85 return true;
88 private function hasMonogram($object) {
89 return method_exists($object, 'getMonogram');