MediaWiki  master
DuplicateJob.php
Go to the documentation of this file.
1 <?php
29 final class DuplicateJob extends Job implements GenericParameterJob {
35  function __construct( array $params ) {
36  parent::__construct( 'duplicate', $params );
37  }
38 
45  public static function newFromJob( RunnableJob $job ) {
46  $djob = new self( $job->getParams() );
47  $djob->command = $job->getType();
48  $djob->params = is_array( $djob->params ) ? $djob->params : [];
49  $djob->params = [ 'isDuplicate' => true ] + $djob->params;
50  $djob->metadata = $job->getMetadata();
51 
52  return $djob;
53  }
54 
55  public function run() {
56  return true;
57  }
58 }
Class to both describe a background job and handle jobs.
Definition: Job.php:30
No-op job that does nothing.
getMetadata( $field=null)
Job that has a run() method and metadata accessors for JobQueue::pop() and JobQueue::ack() ...
Definition: RunnableJob.php:35
run()
Run the job.
if(count( $args)< 1) $job
static newFromJob(RunnableJob $job)
Get a duplicate no-op version of a job.
array $params
Array of job parameters.
Definition: Job.php:35
Interface for generic jobs only uses the parameters field and are JSON serializable.
return true
Definition: router.php:92
__construct(array $params)
Callers should use DuplicateJob::newFromJob() instead.