-
Notifications
You must be signed in to change notification settings - Fork 190
/
DeleteCommand.php
38 lines (31 loc) · 1.19 KB
/
DeleteCommand.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
<?php
namespace Pantheon\Terminus\Commands\MachineToken;
use Pantheon\Terminus\Commands\TerminusCommand;
use Terminus\Exceptions\TerminusException;
class DeleteCommand extends TerminusCommand
{
/**
* @var boolean True if the command requires the user to be logged in
*/
protected $authorized = true;
/**
* Removes a machine token from the logged-in user's account
*
* @name machine-token:delete
* @param string $machine_token_id The ID of the machine token to be deleted
* @throws \Terminus\Exceptions\TerminusException
* @aliases mt:delete
*
* @usage terminus machine-token:delete <machine_token_id>
* Removes the given machine token from the user's account
*/
public function delete($machine_token_id) {
$user = $this->session()->getUser();
// Find the token. Will throw an exception if it doesn't exist.
$machine_token = $user->machine_tokens->get($machine_token_id);
$name = $machine_token->get('device_name');
$this->log()->notice('Deleting {token} ...', ['token' => $name]);
$machine_token->delete();
$this->log()->notice('Deleted {token}!', ['token' => $name]);
}
}