Skip to content

Commit

Permalink
refs #31: Move progress output into callback
Browse files Browse the repository at this point in the history
  • Loading branch information
eFrane committed Nov 24, 2017
1 parent fe687c9 commit 8bfe132
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions lib/Spec/Jobs/ValidatorRunJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class ValidatorRunJob extends Job
*/
protected $canSaveData;

/**
* @var Log
*/
protected $log;

/**
* ValidatorRunJob constructor.
*
Expand All @@ -46,7 +41,6 @@ public function __construct($endpoint, $email, $canSaveData)

public function handle(Log $log, Filesystem $fs)
{
$this->log = $log;
$log->info("Beginning Validation for {$this->endpoint}");

$validatorRepo = new Repository($fs, 'oparl_validator', '');
Expand All @@ -63,21 +57,18 @@ public function handle(Log $log, Filesystem $fs)
$log->debug("Validator command line: {$validator->getCommandLine()}");
$log->debug('Validator Environment', $validator->getEnv());

$validator->run([&$this, 'handleProgress']);
}

public function handleProgress($type, $data)
{
switch ($type) {
case Process::OUT:
try {
$this->log->info($data);
} catch (\Exception $e) {
}
break;
case Process::ERR:
$this->log->error($data);
break;
}
$validator->run(function ($type, $data) use ($log) {
switch ($type) {
case Process::OUT:
try {
$log->info($data);
} catch (\Exception $e) {
}
break;
case Process::ERR:
$log->error($data);
break;
}
});
}
}

0 comments on commit 8bfe132

Please sign in to comment.