GrumPHP\Configuration\ContainerFactory::buildFromConfiguration PHP Method

buildFromConfiguration() public static method

public static buildFromConfiguration ( string $path ) : ContainerBuilder
$path string path to grumphp.yml
return Symfony\Component\DependencyInjection\ContainerBuilder
    public static function buildFromConfiguration($path)
    {
        $container = new ContainerBuilder();
        $container->setProxyInstantiator(new RuntimeInstantiator());
        // Add compiler passes:
        $container->addCompilerPass(new Compiler\ExtensionCompilerPass());
        $container->addCompilerPass(new Compiler\PhpParserCompilerPass());
        $container->addCompilerPass(new Compiler\TaskCompilerPass());
        $container->addCompilerPass(new RegisterListenersPass('event_dispatcher', 'grumphp.event_listener', 'grumphp.event_subscriber'));
        // Load basic service file + custom user configuration
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../../resources/config'));
        $loader->load('formatter.yml');
        $loader->load('linters.yml');
        $loader->load('parameters.yml');
        $loader->load('parsers.yml');
        $loader->load('services.yml');
        $loader->load('subscribers.yml');
        $loader->load('tasks.yml');
        $loader->load('util.yml');
        // Load grumphp.yml file:
        $filesystem = new Filesystem();
        if ($filesystem->exists($path)) {
            $loader->load($path);
        }
        // Compile configuration to make sure that tasks are added to the taskrunner
        $container->compile();
        return $container;
    }

Usage Example

Exemplo n.º 1
0
 function it_should_load_available_tasks_from_the_service_container(ContainerBuilder $container, TaskCompilerPass $taskCompiler)
 {
     $container = ContainerFactory::buildFromConfiguration(__DIR__ . '/../../../resources/config/services.yml');
     $taskCompiler->process($container);
     $this->beConstructedWith($container);
     $this->getTasks()->shouldBeArray();
 }
All Usage Examples Of GrumPHP\Configuration\ContainerFactory::buildFromConfiguration
ContainerFactory