Skip to content

Instantly share code, notes, and snippets.

@rtablada
Created March 20, 2014 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtablada/9655865 to your computer and use it in GitHub Desktop.
Save rtablada/9655865 to your computer and use it in GitHub Desktop.
<?php
// The controller knows too much
Queue::push('Listeners\\UserCreator', [$data])->then(['ConfirmationEmailSender', 'AdminNewUserAlerter', 'MonthlySignupCountUpdater', 'UserTrialActivator']);
// Instead the createUser task should know what to call or better yet, call an event on the event stack before deleting the job
Queue::push('Listeners\\UserCreator', [$attributes]);
class UserCreator {
public function fire($job, $data) {
$user = $this->user->create($data);
Event::fire('queue.user.created');
$job->delete();
}
}
// Then you can dispatch sequential queue jobs, or run them in the same worker process if you want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment