@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class ProjectAddProjectsEmailCommand
4 extends MetaMTAEmailTransactionCommand {
5
6 public function getCommand() {
7 return 'projects';
8 }
9
10 public function getCommandSyntax() {
11 return '**!projects** //#project ...//';
12 }
13
14 public function getCommandSummary() {
15 return pht('Add project tags.');
16 }
17
18 public function getCommandDescription() {
19 return pht(
20 'Associate one or more projects to the object by listing their '.
21 'hashtags. Separate project tags with spaces. For example, use '.
22 '`!projects #ios #feature` to add both related projects.'.
23 "\n\n".
24 'Projects which are invalid or unrecognized will be ignored. This '.
25 'command has no effect if you do not specify any project tags.');
26 }
27
28 public function getCommandAliases() {
29 return array(
30 'project',
31 );
32 }
33
34 public function isCommandSupportedForObject(
35 PhabricatorApplicationTransactionInterface $object) {
36 return ($object instanceof PhabricatorProjectInterface);
37 }
38
39 public function buildTransactions(
40 PhabricatorUser $viewer,
41 PhabricatorApplicationTransactionInterface $object,
42 PhabricatorMetaMTAReceivedMail $mail,
43 $command,
44 array $argv) {
45
46 $project_phids = id(new PhabricatorObjectListQuery())
47 ->setViewer($viewer)
48 ->setAllowedTypes(
49 array(
50 PhabricatorProjectProjectPHIDType::TYPECONST,
51 ))
52 ->setObjectList(implode(' ', $argv))
53 ->setAllowPartialResults(true)
54 ->execute();
55
56 $xactions = array();
57
58 $type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
59 $xactions[] = $object->getApplicationTransactionTemplate()
60 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
61 ->setMetadataValue('edge:type', $type_project)
62 ->setNewValue(
63 array(
64 '+' => array_fuse($project_phids),
65 ));
66
67 return $xactions;
68 }
69
70}