3 final class PhabricatorApplicationObjectMailEngineExtension
4 extends PhabricatorMailEngineExtension
{
6 const EXTENSIONKEY
= 'application/object';
8 public function supportsObject($object) {
12 public function newMailStampTemplates($object) {
14 id(new PhabricatorStringMailStamp())
15 ->setKey('application')
16 ->setLabel(pht('Application')),
19 if ($this->hasMonogram($object)) {
20 $templates[] = id(new PhabricatorStringMailStamp())
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())
30 ->setLabel(pht('Object PHID'));
32 $templates[] = id(new PhabricatorStringMailStamp())
33 ->setKey('object-type')
34 ->setLabel(pht('Object Type'));
40 public function newMailStamps($object, array $xactions) {
41 $editor = $this->getEditor();
42 $viewer = $this->getViewer();
45 $class = $editor->getEditorApplicationClass();
46 if (PhabricatorApplication
::isClassInstalledForViewer($class, $viewer)) {
47 $application = newv($class, array());
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
)) {
81 if (!$object->getConfigOption(LiskDAO
::CONFIG_AUX_PHID
)) {
88 private function hasMonogram($object) {
89 return method_exists($object, 'getMonogram');