Sets a factory.

@param string|array|Reference $factory A PHP function, reference or an array containing a class/Reference and a method to call

@return $this
199825
public function setFactory($factory)
    {
        $this->changes['factory'] = true;

        if (\is_string($factory) && false !== strpos($factory, '::')) {
            $factory = explode('::', $factory, 2);
        } elseif ($factory instanceof Reference) {
            $factory = [$factory, '__invoke'];
        }

        $this->factory = $factory;

        return $this;
    }
217616
public function setFactory(string $factory): Service
    {
        $factoryExploded = explode('::', $factory, 2);

        if (!class_exists($factoryExploded[0]) || !method_exists($factoryExploded[0], $factoryExploded[1])) {
            throw new ContainerException(sprintf('Must be a valid factory class and static method, "%s" given', $factory));
        }

        $this->factory = $factory;

        return $this;
    }
216501
public final void setEntryFactory(Callback<CreateEntryParameter, Entry<?>> factory) {
        Objects.requireNonNull(factory);
        entryFactoryProperty().set(factory);
    }
570979
protected function getFactory($class) {
		if (isset($this->factories[$class])) {
			return $this->factories[$class];
		}

		$factory = new $class($this);
		$this->factories[$class] = $factory;
		return $factory;
	}
114012
public function addFactory(string $key, string $factory): FactoryResolver
    {
        if (is_subclass_of($factory, ServiceFactoryInterface::class, true) === false) {
            throw new InvalidFactoryType($factory);
        }

        $this->factories[$key] = $factory;

        return $this;
    }
825607
public static final void setInstance(FaceletFactory factory)
    {
        if (factory == null)
        {
            instance.remove();
        }
        else
        {
            instance.set(factory);
        }
    }
1334306
protected static function factory($factory)
    {
        if (is_callable($factory)) {
            return $factory();
        }

        $type = gettype($factory);
        if ($type == 'string' && count(EventManager::instance()->listeners($factory)) > 0) {
            return EventManager::instance()->dispatch($factory)->result;
        }

        throw new \InvalidArgumentException('No suitable factory found');
    }
251829
public function addClassMatcherFactory(ClassMatcherFactoryInterface $factory)
    {
        $this->classMatcherFactories[$factory->getType()] = $factory;

        if ($factory instanceof AbstractLogicalFactory) {
            $factory->setNamingStrategy($this);
        }

        return $this;
    }
1179349
function let($client, $factory) {
        $this->client = $client;
        $this->factory = $factory;
        $this->beConstructedWith($client, $factory);
    }
254265
public function setImageFactory($imageFactory)
    {
        if ($imageFactory instanceof Imageoptim || $imageFactory instanceof Optimus) {
            $this->imageFactory = $imageFactory;
        }

        return $this;
    }
761984
function(name, factory, object) {

                        var that = this;
                        var objects = this._resolveObjects(name, factory, object);

                        _.each(objects, function(factoryObjects, factory) {
                            _.each(factoryObjects, function(object, name) {
                                that._setObjectCreator([name], that._createObjectCreator(factory, object));
                            });
                        });

                        return this;
                    }
733672
protected function factory()
    {
        if ($this->factory === null) {
            throw new RuntimeException(
                sprintf('Model Factory is not defined for "%s"', get_class($this))
            );
        }

        return $this->factory;
    }
109959
public function setFactory(array $factories)
    {
        foreach ($factories as $name => $factory) {
            $this->addFactory($name, $factory);
        }

        return $this;
    }
980430
public function setReference($reference = null)
    {
        $reference === null && $reference = PaymentHelper::generateReference($this->getTransactionId());
        $this->params['reference'] = $reference;
        return $this;
    }
503691
private function extended(callable $factory, callable ...$extensions): callable
    {
        return array_reduce($extensions, function ($factory, $extension) {
            return new Extension($factory, $extension);
        }, $factory);
    }
201675
protected function createFromFactory($factory)
    {
        try {
            if (is_string($factory) && class_exists($factory)) {
                $factory = new $factory();
            }

            if (is_callable($factory)) {
                $service  = $factory($this);
            } else {
                throw new ContainerException(
                    'Service could not be created: "There were incorrectly '
                        . 'transmitted data when registering the service".'
                );
            }
        } catch (ContainerException $e) {
            throw $e;
        } catch (\Throwable $e) {
            throw new ContainerException(
                'Service could not be created: "Service factory may be '
                    . 'callable or string (that can be resolving to an '
                    . 'invokable class or to a FactoryInterface instance).'
            );
        }

        return $service;
    }
344277
public function addFactory(FilterBagFactoryInterface $factory, $priority = 0)
    {
        $this->factories[$priority][] = $factory;

        unset($this->sorted);
    }