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

addCreateRepositoryMethod() приватный Метод

Adds the createRepository() method.
private addCreateRepositoryMethod ( Puli\Manager\Api\Php\Clazz $class )
$class Puli\Manager\Api\Php\Clazz The factory class model.
    private function addCreateRepositoryMethod(Clazz $class)
    {
        $method = new Method('createRepository');
        $method->setDescription('Creates the resource repository.');
        $method->setReturnValue(new ReturnValue('$' . self::REPO_VAR_NAME, 'ResourceRepository', 'The created resource repository.'));
        $method->addBody(<<<EOF
if (!interface_exists('Puli\\Repository\\Api\\ResourceRepository')) {
    throw new RuntimeException('Please install puli/repository to create ResourceRepository instances.');
}

EOF
);
        $class->addImport(new Import('Puli\\Repository\\Api\\ResourceRepository'));
        $class->addImport(new Import('RuntimeException'));
        $class->addMethod($method);
        // Add method body
        $config = $this->config;
        $type = $config->get(Config::REPOSITORY_TYPE);
        $options = $this->camelizeKeys($config->get(Config::REPOSITORY));
        $options['root-dir'] = $this->rootDir;
        $options['change-stream'] = $config->get(Config::CHANGE_STREAM);
        $generator = $this->generatorRegistry->getServiceGenerator(GeneratorRegistry::REPOSITORY, $type);
        $generator->generateNewInstance(self::REPO_VAR_NAME, $method, $this->generatorRegistry, $options);
    }