src/Workers/ForkingWorker.php
public function childPerform(BaseJob $job): void
    {
        $loggerContext = ['job' => $job->jid, 'type' => $this->who];

        try {
            if ($this->jobPerformHandler) {
                if ($this->jobPerformHandler instanceof EventsManagerAwareInterface) {
                    $this->jobPerformHandler->setEventsManager($this->client->getEventsManager());
                }

                if (method_exists($this->jobPerformHandler, 'setUp')) {
                    $this->jobPerformHandler->setUp();
                }

                $this->getEventsManager()->fire(new JobEvent\BeforePerform($this->jobPerformHandler, $job));
                $this->jobPerformHandler->perform($job);
                $this->getEventsManager()->fire(new JobEvent\AfterPerform($this->jobPerformHandler, $job));

                if (method_exists($this->jobPerformHandler, 'tearDown')) {
                    $this->jobPerformHandler->tearDown();
                }
            } else {
                $job->perform();
            }

            $this->logger->notice('{type}: job {job} has finished', $loggerContext);
        } catch (\Throwable $e) {
            $loggerContext['stack'] = $e->getMessage();
            $this->logger->critical('{type}: job {job} has failed {stack}', $loggerContext);

            $job->fail(
                'system:fatal',
                sprintf('%s: %s in %s on line %d', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())
            );
        }
    }
public function childPerform(BaseJob $job): void
    {
        $loggerContext = ['job' => $job->jid, 'type' => $this->who];

        try {
            if ($this->jobPerformHandler) {
                if ($this->jobPerformHandler instanceof EventsManagerAwareInterface) {
                    $this->jobPerformHandler->setEventsManager($this->client->getEventsManager());
                }

                if (method_exists($this->jobPerformHandler, 'setUp')) {
                    $this->jobPerformHandler->setUp();
                }

                $this->getEventsManager()->fire(new JobEvent\BeforePerform($this->jobPerformHandler, $job));
                $this->jobPerformHandler->perform($job);
                $this->getEventsManager()->fire(new JobEvent\AfterPerform($this->jobPerformHandler, $job));

                if (method_exists($this->jobPerformHandler, 'tearDown')) {
                    $this->jobPerformHandler->tearDown();
                }
            } else {
                $job->perform();
            }

            $this->logger->notice('{type}: job {job} has finished', $loggerContext);
        } catch (\Throwable $e) {
            $loggerContext['stack'] = $e->getMessage();
            $this->logger->critical('{type}: job {job} has failed {stack}', $loggerContext);

            $job->fail(
                'system:fatal',
                sprintf('%s: %s in %s on line %d', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())
            );
        }
    }
public function childPerform ( BaseJob $ job ) : void { $ loggerContext = [ 'job' => $ job -> jid , 'type' => $ this -> who ] ; try { if ( $ this -> jobPerformHandler ) { if ( $ this -> jobPerformHandler instanceof EventsManagerAwareInterface ) { $ this -> jobPerformHandler -> setEventsManager ( $ this -> client -> getEventsManager ( ) ) ; } if ( method_exists ( $ this -> jobPerformHandler , 'setUp' ) ) { $ this -> jobPerformHandler -> setUp ( ) ; } $ this -> getEventsManager ( ) -> fire ( new JobEvent \ BeforePerform ( $ this -> jobPerformHandler , $ job ) ) ; $ this -> jobPerformHandler -> perform ( $ job ) ; $ this -> getEventsManager ( ) -> fire ( new JobEvent \ AfterPerform ( $ this -> jobPerformHandler , $ job ) ) ; if ( method_exists ( $ this -> jobPerformHandler , 'tearDown' ) ) { $ this -> jobPerformHandler -> tearDown ( ) ; } } else { $ job -> perform ( ) ; } $ this -> logger -> notice ( '{type}: job {job} has finished' , $ loggerContext ) ; } catch ( \ Throwable $ e ) { $ loggerContext [ 'stack' ] = $ e -> getMessage ( ) ; $ this -> logger -> critical ( '{type}: job {job} has failed {stack}' , $ loggerContext ) ; $ job -> fail ( 'system:fatal' , sprintf ( '%s: %s in %s on line %d' , get_class ( $ e ) , $ e -> getMessage ( ) , $ e -> getFile ( ) , $ e -> getLine ( ) ) ) ; } }
Process a single job.

@param  BaseJob $job The job to be processed.
@return void
Process a single job .