DependencyInjection/CompilerPass/RepositoryCompilerPass.php
private function createSearchRepository(
        ContainerBuilder $container,
        string $name,
        array $repositoryConfiguration,
        string $indexName
    ) {
        $repositoryName = "apisearch.repository_$name.$indexName";
        $repositoryTransformableName = "apisearch.repository_transformable_$name.$indexName";
        $clientName = "apisearch.client_$name";

        switch ($repositoryConfiguration['adapter']) {
            case 'in_memory':
                $repositoryDefinition = $container
                    ->register($repositoryName, InMemoryRepository::class)
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'disk':
                $repositoryDefinition = $container
                    ->register($repositoryName, DiskRepository::class)
                    ->addArgument($repositoryConfiguration['disk_file'].'.'.$name)
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'http':
            case 'http_test':
                $repositoryDefinition = $container
                    ->register($repositoryName, HttpRepository::class)
                    ->addArgument(new Reference($clientName))
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'service':
                $container->setAlias($repositoryName, $repositoryConfiguration['search']['repository_service']);
                $aliasDefinition = $container->getAlias($repositoryName);
                $aliasDefinition->setPublic($this->repositoryIsTest($repositoryConfiguration));
                $repositoryDefinition = $container->getDefinition($repositoryConfiguration['search']['repository_service']);
                break;
        }

        $this->injectRepositoryCredentials(
            $repositoryDefinition,
            $name,
            $repositoryConfiguration,
            $indexName
        );

        $definition = $container
            ->register($repositoryTransformableName, TransformableRepository::class)
            ->setDecoratedService($repositoryName)
            ->addArgument(new Reference($repositoryTransformableName.'.inner'))
            ->addArgument(new Reference('apisearch.transformer'))
            ->setPublic($this->repositoryIsTest($repositoryConfiguration));

        $this->injectRepositoryCredentials(
            $definition,
            $name,
            $repositoryConfiguration,
            $indexName
        );

        $container
            ->getDefinition('apisearch.repository_bucket')
            ->addMethodCall(
                'addRepository',
                [$name, $indexName, new Reference($repositoryName)]
            )
            ->setPublic($this->repositoryIsTest($repositoryConfiguration));
    }
private function createSearchRepository(
        ContainerBuilder $container,
        string $name,
        array $repositoryConfiguration,
        string $indexName
    ) {
        $repositoryName = "apisearch.repository_$name.$indexName";
        $repositoryTransformableName = "apisearch.repository_transformable_$name.$indexName";
        $clientName = "apisearch.client_$name";

        switch ($repositoryConfiguration['adapter']) {
            case 'in_memory':
                $repositoryDefinition = $container
                    ->register($repositoryName, InMemoryRepository::class)
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'disk':
                $repositoryDefinition = $container
                    ->register($repositoryName, DiskRepository::class)
                    ->addArgument($repositoryConfiguration['disk_file'].'.'.$name)
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'http':
            case 'http_test':
                $repositoryDefinition = $container
                    ->register($repositoryName, HttpRepository::class)
                    ->addArgument(new Reference($clientName))
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'service':
                $container->setAlias($repositoryName, $repositoryConfiguration['search']['repository_service']);
                $aliasDefinition = $container->getAlias($repositoryName);
                $aliasDefinition->setPublic($this->repositoryIsTest($repositoryConfiguration));
                $repositoryDefinition = $container->getDefinition($repositoryConfiguration['search']['repository_service']);
                break;
        }

        $this->injectRepositoryCredentials(
            $repositoryDefinition,
            $name,
            $repositoryConfiguration,
            $indexName
        );

        $definition = $container
            ->register($repositoryTransformableName, TransformableRepository::class)
            ->setDecoratedService($repositoryName)
            ->addArgument(new Reference($repositoryTransformableName.'.inner'))
            ->addArgument(new Reference('apisearch.transformer'))
            ->setPublic($this->repositoryIsTest($repositoryConfiguration));

        $this->injectRepositoryCredentials(
            $definition,
            $name,
            $repositoryConfiguration,
            $indexName
        );

        $container
            ->getDefinition('apisearch.repository_bucket')
            ->addMethodCall(
                'addRepository',
                [$name, $indexName, new Reference($repositoryName)]
            )
            ->setPublic($this->repositoryIsTest($repositoryConfiguration));
    }
private function createSearchRepository ( ContainerBuilder $ container , string $ name , array $ repositoryConfiguration , string $ indexName ) { $ repositoryName = "apisearch.repository_$name.$indexName" ; $ repositoryTransformableName = "apisearch.repository_transformable_$name.$indexName" ; $ clientName = "apisearch.client_$name" ; switch ( $ repositoryConfiguration [ 'adapter' ] ) { case 'in_memory' : $ repositoryDefinition = $ container -> register ( $ repositoryName , InMemoryRepository :: class ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; break ; case 'disk' : $ repositoryDefinition = $ container -> register ( $ repositoryName , DiskRepository :: class ) -> addArgument ( $ repositoryConfiguration [ 'disk_file' ] . '.' . $ name ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; break ; case 'http' : case 'http_test' : $ repositoryDefinition = $ container -> register ( $ repositoryName , HttpRepository :: class ) -> addArgument ( new Reference ( $ clientName ) ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; break ; case 'service' : $ container -> setAlias ( $ repositoryName , $ repositoryConfiguration [ 'search' ] [ 'repository_service' ] ) ; $ aliasDefinition = $ container -> getAlias ( $ repositoryName ) ; $ aliasDefinition -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; $ repositoryDefinition = $ container -> getDefinition ( $ repositoryConfiguration [ 'search' ] [ 'repository_service' ] ) ; break ; } $ this -> injectRepositoryCredentials ( $ repositoryDefinition , $ name , $ repositoryConfiguration , $ indexName ) ; $ definition = $ container -> register ( $ repositoryTransformableName , TransformableRepository :: class ) -> setDecoratedService ( $ repositoryName ) -> addArgument ( new Reference ( $ repositoryTransformableName . '.inner' ) ) -> addArgument ( new Reference ( 'apisearch.transformer' ) ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; $ this -> injectRepositoryCredentials ( $ definition , $ name , $ repositoryConfiguration , $ indexName ) ; $ container -> getDefinition ( 'apisearch.repository_bucket' ) -> addMethodCall ( 'addRepository' , [ $ name , $ indexName , new Reference ( $ repositoryName ) ] ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; }
Create a repository by connection configuration.

@param ContainerBuilder $container
@param string           $name
@param array            $repositoryConfiguration
@param string           $indexName
Create a repository by connection configuration .