for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
class CreateEnvJob extends DeploynautJob {
/**
*
* @var array
*/
public $args;
public function setUp() {
$this->updateStatus('Started');
chdir(BASE_PATH);
}
public function perform() {
echo "[-] CreateEnvJob starting" . PHP_EOL;
$log = new DeploynautLogFile($this->args['logfile']);
$envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
// This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
try {
if(!($envCreate && $envCreate->exists())) {
throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID']));
// This will throw and exception if it fails.
$envCreate->createEnvironment();
} catch(Exception $e) {
$log->write($e->getMessage());
echo "[-] CreateEnvJob failed" . PHP_EOL;
throw $e;
$this->updateStatus('Finished');
echo "[-] CreateEnvJob finished" . PHP_EOL;
* @param string $status
* @global array $databaseConfig
protected function updateStatus($status) {
global $databaseConfig;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
DB::connect($databaseConfig);
$record = DNCreateEnvironment::get()->byID($this->args['createID']);
$record->Status = $status;
$record->write();
* @return DNData
protected function DNData() {
return DNData::inst();
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state