Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Ensure encrypter exists #14038

Merged
merged 5 commits into from
Jun 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use DateTime;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Support\Arr;
use SuperClosure\Serializer;
use Illuminate\Container\Container;
Expand All @@ -19,6 +20,11 @@ abstract class Queue
*/
protected $container;

/**
* @var \Illuminate\Contracts\Encryption\Encrypter
*/
protected $crypt;

/**
* Push a new job onto the queue.
*
Expand Down Expand Up @@ -144,7 +150,7 @@ protected function prepareQueueableEntity($value)
*/
protected function createClosurePayload($job, $data)
{
$closure = $this->crypt->encrypt((new Serializer)->serialize($job));
$closure = $this->getEncrypter()->encrypt((new Serializer)->serialize($job));

return ['job' => 'IlluminateQueueClosure', 'data' => compact('closure')];
}
Expand Down Expand Up @@ -210,4 +216,18 @@ public function setEncrypter(EncrypterContract $crypt)
{
$this->crypt = $crypt;
}

/**
* @return EncrypterContract
*
* @throws EncryptException
*/
protected function getEncrypter()
{
if (null === $this->crypt) {
throw new EncryptException('No encrypter set for Queue');
}

return $this->crypt;
}
}