Puli\Manager\Factory\FactoryManagerImpl::createFactory PHP Метод

createFactory() публичный Метод

public createFactory ( $path = null, $className = null )
    public function createFactory($path = null, $className = null)
    {
        Assert::nullOrStringNotEmpty($path, 'The path to the generated factory file must be a non-empty string or null. Got: %s');
        Assert::nullOrStringNotEmpty($className, 'The class name of the generated factory must be a non-empty string or null. Got: %s');
        $this->refreshFactoryClass($path, $className);
        $className = $className ?: $this->config->get(Config::FACTORY_IN_CLASS);
        $path = $path ?: $this->config->get(Config::FACTORY_IN_FILE);
        if (null !== $path && !class_exists($className, false)) {
            require_once Path::makeAbsolute($path, $this->rootDir);
        }
        return new $className();
    }

Usage Example

Пример #1
0
 public function testCreateFactoryWithExistingAutoLoadableClass()
 {
     $this->assertFalse(class_exists('Puli\\Manager\\Tests\\Factory\\Fixtures\\TestFactory', false));
     $this->context->getConfig()->set(Config::FACTORY_IN_FILE, null);
     $this->context->getConfig()->set(Config::FACTORY_IN_CLASS, 'Puli\\Manager\\Tests\\Factory\\Fixtures\\TestFactory');
     $factory = $this->manager->createFactory();
     $this->assertInstanceOf('Puli\\Manager\\Tests\\Factory\\Fixtures\\TestFactory', $factory);
 }
All Usage Examples Of Puli\Manager\Factory\FactoryManagerImpl::createFactory