Skip to content

Commit

Permalink
Updated example to use Serializer and "closure" config key.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carson Full committed Dec 8, 2015
1 parent d75fe89 commit 353f1bb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions resources/jobby-pdo.php
Expand Up @@ -68,8 +68,9 @@
echo "I'm a function (" . date('Y-m-d H:i:s') . ')!' . PHP_EOL;
return true;
};
$secondJobFnSerializable = new \SuperClosure\SerializableClosure($secondJobFn);
$secondJobFnSerialized = serialize($secondJobFnSerializable);
$serializer = new SuperClosure\Serializer();

$secondJobFnSerialized = $serializer->serialize($secondJobFn);
$insertCronJobConfiguration->execute(
['ClosureExample', $secondJobFnSerialized, '* * * * *', 'logs/closure-pdo.log']
);
Expand All @@ -89,11 +90,10 @@
// Filter out each value, which is not set (for example, "maxRuntime" is not defined in the job).
$job = array_filter($job);

$commandUnserialized = @unserialize($job['command']);
if (false !== $commandUnserialized) {
assert($commandUnserialized instanceof \SuperClosure\SerializableClosure);

$job['command'] = $commandUnserialized;
try {
$job['closure'] = $serializer->unserialize($job['command']);
unset($job['command']);
} catch (SuperClosure\Exception\ClosureUnserializationException $e) {
}

$jobName = $job['name'];
Expand Down

0 comments on commit 353f1bb

Please sign in to comment.