Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/management/PhabricatorPeopleManagementWorkflow.php
12256 views
1
<?php
2
3
abstract class PhabricatorPeopleManagementWorkflow
4
extends PhabricatorManagementWorkflow {
5
6
final protected function getUserSelectionArguments() {
7
return array(
8
array(
9
'name' => 'user',
10
'param' => 'username',
11
'help' => pht('User account to act on.'),
12
),
13
);
14
}
15
16
final protected function selectUser(PhutilArgumentParser $argv) {
17
$username = $argv->getArg('user');
18
19
if (!strlen($username)) {
20
throw new PhutilArgumentUsageException(
21
pht(
22
'Select a user account to act on with "--user <username>".'));
23
}
24
25
$user = id(new PhabricatorPeopleQuery())
26
->setViewer($this->getViewer())
27
->withUsernames(array($username))
28
->executeOne();
29
if (!$user) {
30
throw new PhutilArgumentUsageException(
31
pht(
32
'No user with username "%s" exists.',
33
$username));
34
}
35
36
return $user;
37
}
38
39
final protected function applyTransactions(
40
PhabricatorUser $user,
41
array $xactions) {
42
assert_instances_of($xactions, 'PhabricatorUserTransaction');
43
44
$viewer = $this->getViewer();
45
$application = id(new PhabricatorPeopleApplication())->getPHID();
46
$content_source = $this->newContentSource();
47
48
$editor = $user->getApplicationTransactionEditor()
49
->setActor($viewer)
50
->setActingAsPHID($application)
51
->setContentSource($content_source)
52
->setContinueOnMissingFields(true);
53
54
return $editor->applyTransactions($user, $xactions);
55
}
56
57
}
58
59