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