mirror of
https://github.com/idanoo/php-resque
synced 2025-06-30 21:22:20 +00:00
add beforeEnqueue hook that allows the enqueue to be cancelled
This commit is contained in:
parent
c335bc3555
commit
a95c24b32e
5 changed files with 106 additions and 29 deletions
|
@ -50,14 +50,17 @@ class Resque_Job
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function create($queue, $class, $args = null, $monitor = false)
|
||||
public static function create($queue, $class, $args = null, $monitor = false, $id = null)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
$id = Resque::generateJobId();
|
||||
}
|
||||
|
||||
if($args !== null && !is_array($args)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Supplied $args must be an array.'
|
||||
);
|
||||
}
|
||||
$id = md5(uniqid('', true));
|
||||
Resque::push($queue, array(
|
||||
'class' => $class,
|
||||
'args' => array($args),
|
||||
|
|
12
lib/Resque/Job/DontCreate.php
Normal file
12
lib/Resque/Job/DontCreate.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Exception to be thrown if while enqueuing a job it should not be created.
|
||||
*
|
||||
* @package Resque/Job
|
||||
* @author Chris Boulton <chris@bigcommerce.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
class Resque_Job_DontCreate extends Exception
|
||||
{
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue