Created
March 20, 2014 02:08
-
-
Save rtablada/9655865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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