1 | <?php |
||
13 | class UpdateTicketTask implements Task |
||
14 | { |
||
15 | /** @var string */ |
||
16 | private $path; |
||
17 | |||
18 | /** @var Ticket */ |
||
19 | private $ticket; |
||
20 | |||
21 | /** @var Parameters */ |
||
22 | private $applicationParams; |
||
23 | |||
24 | /** @var FileManagerService */ |
||
25 | private $fileManager; |
||
26 | |||
27 | 1 | public function __construct(Ticket $ticket, Parameters $applicationParams, FileManagerService $fileManager) |
|
34 | |||
35 | /** |
||
36 | * Updates application code, if tickets status changes to 'work finished'. |
||
37 | * |
||
38 | * @throws DirectoryNotFoundException |
||
39 | * @throws IOException |
||
40 | */ |
||
41 | 1 | public function execute() : bool |
|
48 | |||
49 | /** |
||
50 | * Runs git clone command in ticket directory. Returns true when process is finished. |
||
51 | * Uses SSH key for authorization. |
||
52 | * |
||
53 | * @throws DirectoryNotFoundException |
||
54 | */ |
||
55 | 1 | private function executeGitPull(string $path) : bool |
|
63 | |||
64 | /** |
||
65 | * Combines string with valid git pull command. |
||
66 | */ |
||
67 | 1 | private function combinePullCommand(string $branch) : string |
|
71 | |||
72 | /** |
||
73 | * Creates file with tickets current status and timestamp inside ticket dir. |
||
74 | * |
||
75 | * @throws IOException |
||
76 | */ |
||
77 | 1 | private function createSnapshot() : bool |
|
85 | |||
86 | /** |
||
87 | * Runs composer install command in ticket directory. |
||
88 | * Returns true when process is finished. |
||
89 | */ |
||
90 | 1 | private function executeComposerInstall(string $path) : bool |
|
96 | } |
||
97 |