Mmoreram\GearmanBundle\Service\GearmanExecute::createJob PHP Method

createJob() private method

Given a worker settings, return Job instance
private createJob ( array $worker ) : Object
$worker array Worker settings
return Object Job instance
    private function createJob(array $worker)
    {
        /**
         * If service is defined, we must retrieve this class with dependency injection
         *
         * Otherwise we just create it with a simple new()
         */
        if ($worker['service']) {
            $objInstance = $this->container->get($worker['service']);
        } else {
            $objInstance = new $worker['className']();
            /**
             * If instance of given object is instanceof
             * ContainerAwareInterface, we inject full container by calling
             * container setter.
             *
             * @see https://github.com/mmoreram/gearman-bundle/pull/12
             */
            if ($objInstance instanceof ContainerAwareInterface) {
                $objInstance->setContainer($this->container);
            }
        }
        return $objInstance;
    }