SHARE
TWEET

Untitled

a guest Jul 17th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function __set($property, $value)
  2. {
  3.     $this->{$property} = $value
  4.     $this->update();
  5. }
  6.  
  7. /**
  8.  * Call this if you want to persist your property updates between fails or retries.
  9.  * This will update "payload".
  10.  **/
  11. public function update()
  12. {
  13.   // get top level Job (\Illuminate\Queue\Jobs\Job)
  14.   $job = $this->job;
  15.   $refobject = new \ReflectionObject($job);
  16.  
  17.   // get it's job property
  18.   $jobrecord = $refobject->getProperty('job');
  19.   $jobrecord->setAccessible(true);
  20.  
  21.   // create a new reflection object of the next job property ($jobrecord)
  22.   $record = $jobrecord->getValue($job);
  23.   $refobject = new \ReflectionObject($record);
  24.  
  25.   // with our new reflection object, access the record property
  26.   $recordproperty = $refobject->getProperty('record');
  27.   $recordproperty->setAccessible(true);
  28.  
  29.   // get the record property and fetch the payload from it.
  30.   $record = $recordproperty->getValue($record);
  31.   $payload = $record->payload;
  32.  
  33.   $payload = \json_decode($payload, true);
  34.  
  35.   // keep job, but null it while we serialize as we don't need it to be stored.
  36.   $job = $this->job;
  37.   $this->job = null;
  38.  
  39.   // overwrite the serialized object with a new copy of it.
  40.   $payload['data']['command'] = \serialize($this);
  41.  
  42.   // reset the job after serialization
  43.   $this->job = $job;
  44.   $record->payload = \json_encode($payload);
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top