Creating jobs - xaav/XaavQueueBundle GitHub Wiki
Once you have successfully installed the bundle, the next step is to create some jobs.
Creating the Job class
Create the following file (you can infer it's path from the namespace):
<?php
namespace YourVendor\YourBundle\Job;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Xaav\QueueBundle\Queue\Job\JobInterface;
class SendEmailJob extends ContainerAware implements ContainerAwareInterface, JobInterface
{
protected $from;
protected $to;
protected $body;
public function __construct($from, $to, $body)
{
$this->from = $from;
$this->to = $to;
$this->body = $body;
}
public function process()
{
$mailer = $this->get('mailer');
//Send the message
}
}
Now, to send a message in your application, simply use:
<?php
$container->get('xaav.queue.manager')->get('your_vendor_your')->add(new SendEmailJob($from, $to, $body));
The job will automatically be queued and processed later.