| @@ 15-93 (lines=79) @@ | ||
| 12 | * |
|
| 13 | * @package Acacha\ForgePublish\Commands |
|
| 14 | */ |
|
| 15 | class PublishAssignments extends Command |
|
| 16 | { |
|
| 17 | ||
| 18 | use ItFetchesAssignments, AborstIfEnvVariableIsnotInstalled; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * The name and signature of the console command. |
|
| 22 | * |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | protected $signature = 'publish:assignments'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * The console command description. |
|
| 29 | * |
|
| 30 | * @var string |
|
| 31 | */ |
|
| 32 | protected $description = 'List current teacher assignments'; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Assignments. |
|
| 36 | * |
|
| 37 | * @var |
|
| 38 | */ |
|
| 39 | protected $assignments; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Server names. |
|
| 43 | * |
|
| 44 | * @var Client |
|
| 45 | */ |
|
| 46 | protected $http; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * SaveEnvVariable constructor. |
|
| 50 | * |
|
| 51 | */ |
|
| 52 | public function __construct(Client $http) |
|
| 53 | { |
|
| 54 | parent::__construct(); |
|
| 55 | $this->http = $http; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Execute the console command. |
|
| 60 | * |
|
| 61 | */ |
|
| 62 | public function handle() |
|
| 63 | { |
|
| 64 | $this->abortCommandExecution(); |
|
| 65 | $this->assignments = $this->fetchAssignments(); |
|
| 66 | ||
| 67 | $headers = ['Id', 'Name','Repository','Repo Type','Forge site','Forge Server','Created','Updated']; |
|
| 68 | ||
| 69 | $rows = []; |
|
| 70 | foreach ($this->assignments as $assignment) { |
|
| 71 | $rows[] = [ |
|
| 72 | $assignment->id, |
|
| 73 | $assignment->name, |
|
| 74 | $assignment->repository_uri, |
|
| 75 | $assignment->repository_type, |
|
| 76 | $assignment->forge_site, |
|
| 77 | $assignment->forge_server, |
|
| 78 | $assignment->created_at, |
|
| 79 | $assignment->updated_at |
|
| 80 | ]; |
|
| 81 | } |
|
| 82 | ||
| 83 | $this->table($headers, $rows); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Abort command execution. |
|
| 88 | */ |
|
| 89 | protected function abortCommandExecution() |
|
| 90 | { |
|
| 91 | $this->abortsIfEnvVarIsNotInstalled('ACACHA_FORGE_ACCESS_TOKEN'); |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||
| @@ 15-94 (lines=80) @@ | ||
| 12 | * |
|
| 13 | * @package Acacha\ForgePublish\Commands |
|
| 14 | */ |
|
| 15 | class PublishTodo extends Command |
|
| 16 | { |
|
| 17 | ||
| 18 | use ItFetchesAssignments, AborstIfEnvVariableIsnotInstalled; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * The name and signature of the console command. |
|
| 22 | * |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | protected $signature = 'publish:todo'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * The console command description. |
|
| 29 | * |
|
| 30 | * @var string |
|
| 31 | */ |
|
| 32 | protected $description = 'List current student assignments'; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Assignments. |
|
| 36 | * |
|
| 37 | * @var |
|
| 38 | */ |
|
| 39 | protected $assignments; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Server names. |
|
| 43 | * |
|
| 44 | * @var Client |
|
| 45 | */ |
|
| 46 | protected $http; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * SaveEnvVariable constructor. |
|
| 50 | * |
|
| 51 | */ |
|
| 52 | public function __construct(Client $http) |
|
| 53 | { |
|
| 54 | parent::__construct(); |
|
| 55 | $this->http = $http; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Execute the console command. |
|
| 60 | * |
|
| 61 | */ |
|
| 62 | public function handle() |
|
| 63 | { |
|
| 64 | //TODO |
|
| 65 | $this->abortCommandExecution(); |
|
| 66 | $this->assignments = $this->fetchAssignments(); |
|
| 67 | ||
| 68 | $headers = ['Id', 'Name','Repository','Repo Type','Forge site','Forge Server','Created','Updated']; |
|
| 69 | ||
| 70 | $rows = []; |
|
| 71 | foreach ($this->assignments as $assignment) { |
|
| 72 | $rows[] = [ |
|
| 73 | $assignment->id, |
|
| 74 | $assignment->name, |
|
| 75 | $assignment->repository_uri, |
|
| 76 | $assignment->repository_type, |
|
| 77 | $assignment->forge_site, |
|
| 78 | $assignment->forge_server, |
|
| 79 | $assignment->created_at, |
|
| 80 | $assignment->updated_at |
|
| 81 | ]; |
|
| 82 | } |
|
| 83 | ||
| 84 | $this->table($headers, $rows); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Abort command execution. |
|
| 89 | */ |
|
| 90 | protected function abortCommandExecution() |
|
| 91 | { |
|
| 92 | $this->abortsIfEnvVarIsNotInstalled('ACACHA_FORGE_ACCESS_TOKEN'); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||