| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function perform() { |
||
| 22 | echo "[-] CreateEnvJob starting" . PHP_EOL; |
||
| 23 | |||
| 24 | $log = new DeploynautLogFile($this->args['logfile']); |
||
| 25 | $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']); |
||
| 26 | |||
| 27 | // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque |
||
| 28 | try { |
||
| 29 | if(!($envCreate && $envCreate->exists())) { |
||
| 30 | throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID'])); |
||
| 31 | } |
||
| 32 | |||
| 33 | // This will throw and exception if it fails. |
||
| 34 | $envCreate->createEnvironment(); |
||
| 35 | |||
| 36 | } catch(Exception $e) { |
||
| 37 | $log->write($e->getMessage()); |
||
| 38 | echo "[-] CreateEnvJob failed" . PHP_EOL; |
||
| 39 | throw $e; |
||
| 40 | } |
||
| 41 | $this->updateStatus('Finished'); |
||
| 42 | echo "[-] CreateEnvJob finished" . PHP_EOL; |
||
| 43 | } |
||
| 44 | |||
| 68 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state