Skip to content

Commit

Permalink
Clean up display name code a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 6, 2017
1 parent c9e8854 commit 4e85a9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/Jobs/JobName.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public static function parse($job)
*/
public static function resolve($name, $payload)
{
if (isset($payload['name']) && ! empty($payload['name'])) {
return $payload['name'];
if (isset($payload['displayName']) && ! empty($payload['displayName'])) {
return $payload['displayName'];
}

if ($name === 'Illuminate\Queue\CallQueuedHandler@call') {
Expand Down
17 changes: 16 additions & 1 deletion src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ protected function createPayloadArray($job, $data = '', $queue = null)
protected function createObjectPayload($job)
{
return [
'displayName' => $this->getDisplayName($job),
'job' => 'Illuminate\Queue\CallQueuedHandler@call',
'maxTries' => isset($job->tries) ? $job->tries : null,
'name' => $job instanceof CallQueuedListener ? $job->class : '',
'timeout' => isset($job->timeout) ? $job->timeout : null,
'data' => [
'commandName' => get_class($job),
Expand All @@ -128,6 +128,21 @@ protected function createObjectPayload($job)
];
}

/**
* Get the display name for the given job.
*
* @param mixed $job
* @return string
*/
protected function getDisplayName($job)
{
if ($job instanceof CallQueuedListener) {
return $job->class;
}

return get_class($job);
}

/**
* Create a typical, string based queue payload array.
*
Expand Down

0 comments on commit 4e85a9a

Please sign in to comment.