1 | <?php namespace G2R; |
||
12 | class Adapter |
||
13 | { |
||
14 | use LoggerTrait; |
||
15 | |||
16 | protected $logger; |
||
17 | |||
18 | protected $jobRunner; |
||
19 | |||
20 | protected $projectsConfig; |
||
21 | |||
22 | protected $hook; |
||
23 | |||
24 | protected $input; |
||
25 | |||
26 | public static function factory( |
||
45 | |||
46 | /** |
||
47 | * Eventually attach a Logger |
||
48 | * |
||
49 | * @param LoggerInterface|null $logger |
||
50 | */ |
||
51 | 12 | public function __construct(LoggerInterface $logger = null) |
|
55 | |||
56 | /** |
||
57 | * Run the adapter |
||
58 | * |
||
59 | * @throws Exception |
||
60 | */ |
||
61 | 10 | public function run() |
|
86 | |||
87 | /** |
||
88 | * Load the rundeck job runner |
||
89 | * |
||
90 | * @param JobRunner $jobRunner |
||
91 | */ |
||
92 | 8 | public function attachJobRunner(JobRunner $jobRunner) |
|
100 | |||
101 | /** |
||
102 | * Load the projects config |
||
103 | * |
||
104 | * @param ProjectConfig $projectsConfig |
||
105 | */ |
||
106 | 8 | public function loadProjectsConfig(ProjectConfig $projectsConfig) |
|
114 | |||
115 | 10 | private function getProjectsConfig() |
|
123 | |||
124 | 6 | private function getJobRunner() |
|
132 | |||
133 | /** |
||
134 | * Get the hook |
||
135 | * |
||
136 | * @return HookResolver |
||
137 | */ |
||
138 | 8 | private function getHook() |
|
148 | |||
149 | /** |
||
150 | * Get the input (php://input by default) |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | private function getInput() |
||
166 | |||
167 | 10 | public function setHook(GitlabHook $hook) |
|
171 | |||
172 | public function setInput($input) |
||
176 | |||
177 | /** |
||
178 | * Call the logger |
||
179 | * |
||
180 | * @param $level |
||
181 | * @param $message |
||
182 | * @param array $context |
||
183 | */ |
||
184 | 12 | public function log($level, $message, array $context = array()) |
|
190 | } |
||
191 |