/** * Prepare the instance for serialization. * * @return array All the properties to serialize */ public function __sleep() { $this->bag->serialize(); $this->previousPipes = array_map(function ($pipe) { return new PipeIdentifier($pipe); }, $this->previousPipes); $this->nextPipe = new PipeIdentifier($this->nextPipe); $this->progress = new ModelIdentifier(get_class($this->progress), $this->progress->getKey()); return ['previousPipes', 'nextPipe', 'bag', 'progress']; }
/** * Updates the progress to be at the end of the pipe * * @param Traveler $traveler Traveler to store * @param Pipe $pipe Pipe the traveler is going to next * * @return void */ public function endOfPipe(Traveler $traveler, Pipe $pipe) { if ($traveler->nextPipe !== null) { // Create new traveler progress (and thus new traveler) if this // isn't the first pipe to be processed. $progress = new TravelerProgress(); $progress->initialiseProgress(); $progress->stream()->associate($this->stream); $progress->status = 'Traveling'; $progress->pipeable()->associate($pipe->getModel()); $progress->save(); $traveler->progress = $progress; return; } $this->status = 'Traveling'; $this->pipeable()->associate($pipe->getModel()); $this->save(); }