DependencyInjection/CompilerPass/RepositoryCompilerPass.php
private function createStandardRepository(
        ContainerBuilder $container,
        string $appName,
        array $repositoryConfiguration,
        string $indexName,
        string $prefix,
        string $inMemoryRepositoryNamespace,
        string $diskRepositoryNamespace,
        string $httpRepositoryNamespace
    ) {
        $repositoryName = rtrim("apisearch.{$prefix}_repository_$appName.$indexName", '.');
        $tokenUUIDName = rtrim("apisearch.token_uuid.$appName");
        $clientName = rtrim("apisearch.client_$appName", '.');

        $tokenUUIDReference = $container->register($tokenUUIDName, TokenUUID::class);
        $tokenUUIDReference
            ->setFactory([
                TokenUUID::class,
                'createById',
            ])
            ->addArgument((string) $repositoryConfiguration['token'])
            ->setPrivate(true);

        $repositoryReferenceName = rtrim("apisearch.repository_reference.$appName.$indexName", '.');
        $repositoryReferenceReference = new Reference($repositoryReferenceName);

        switch ($repositoryConfiguration['adapter']) {
            case 'in_memory':
                $container
                    ->register($repositoryName, $inMemoryRepositoryNamespace)
                    ->addMethodCall('setRepositoryReference', [
                        $repositoryReferenceReference,
                    ])
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'disk':
                $container
                    ->register($repositoryName, $diskRepositoryNamespace)
                    ->addMethodCall('setRepositoryReference', [
                        $repositoryReferenceReference,
                    ])
                    ->addArgument($repositoryConfiguration['disk_file'].'.'.$prefix.'.'.$appName)
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'http':
            case 'http_test':
                $container
                    ->register($repositoryName, $httpRepositoryNamespace)
                    ->addArgument(new Reference($clientName))
                    ->addMethodCall('setCredentials', [
                        $repositoryReferenceReference,
                        new Reference($tokenUUIDName),
                    ])
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'service':
                $repoDefinition = $container->getDefinition($repositoryConfiguration[$prefix]['repository_service']);
                $this->injectRepositoryCredentials(
                    $repoDefinition,
                    $appName,
                    $repositoryConfiguration,
                    $indexName
                );

                $container->setAlias($repositoryName, $repositoryConfiguration[$prefix]['repository_service']);
                $aliasDefinition = $container->getAlias($repositoryName);
                $aliasDefinition->setPublic($this->repositoryIsTest($repositoryConfiguration));
        }

        $container
            ->getDefinition("apisearch.{$prefix}_repository_bucket")
            ->addMethodCall(
                'addRepository',
                [$appName, new Reference($repositoryName)]
            )
            ->setPublic($this->repositoryIsTest($repositoryConfiguration));
    }
private function createStandardRepository(
        ContainerBuilder $container,
        string $appName,
        array $repositoryConfiguration,
        string $indexName,
        string $prefix,
        string $inMemoryRepositoryNamespace,
        string $diskRepositoryNamespace,
        string $httpRepositoryNamespace
    ) {
        $repositoryName = rtrim("apisearch.{$prefix}_repository_$appName.$indexName", '.');
        $tokenUUIDName = rtrim("apisearch.token_uuid.$appName");
        $clientName = rtrim("apisearch.client_$appName", '.');

        $tokenUUIDReference = $container->register($tokenUUIDName, TokenUUID::class);
        $tokenUUIDReference
            ->setFactory([
                TokenUUID::class,
                'createById',
            ])
            ->addArgument((string) $repositoryConfiguration['token'])
            ->setPrivate(true);

        $repositoryReferenceName = rtrim("apisearch.repository_reference.$appName.$indexName", '.');
        $repositoryReferenceReference = new Reference($repositoryReferenceName);

        switch ($repositoryConfiguration['adapter']) {
            case 'in_memory':
                $container
                    ->register($repositoryName, $inMemoryRepositoryNamespace)
                    ->addMethodCall('setRepositoryReference', [
                        $repositoryReferenceReference,
                    ])
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'disk':
                $container
                    ->register($repositoryName, $diskRepositoryNamespace)
                    ->addMethodCall('setRepositoryReference', [
                        $repositoryReferenceReference,
                    ])
                    ->addArgument($repositoryConfiguration['disk_file'].'.'.$prefix.'.'.$appName)
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'http':
            case 'http_test':
                $container
                    ->register($repositoryName, $httpRepositoryNamespace)
                    ->addArgument(new Reference($clientName))
                    ->addMethodCall('setCredentials', [
                        $repositoryReferenceReference,
                        new Reference($tokenUUIDName),
                    ])
                    ->setPublic($this->repositoryIsTest($repositoryConfiguration));
                break;

            case 'service':
                $repoDefinition = $container->getDefinition($repositoryConfiguration[$prefix]['repository_service']);
                $this->injectRepositoryCredentials(
                    $repoDefinition,
                    $appName,
                    $repositoryConfiguration,
                    $indexName
                );

                $container->setAlias($repositoryName, $repositoryConfiguration[$prefix]['repository_service']);
                $aliasDefinition = $container->getAlias($repositoryName);
                $aliasDefinition->setPublic($this->repositoryIsTest($repositoryConfiguration));
        }

        $container
            ->getDefinition("apisearch.{$prefix}_repository_bucket")
            ->addMethodCall(
                'addRepository',
                [$appName, new Reference($repositoryName)]
            )
            ->setPublic($this->repositoryIsTest($repositoryConfiguration));
    }
private function createStandardRepository ( ContainerBuilder $ container , string $ appName , array $ repositoryConfiguration , string $ indexName , string $ prefix , string $ inMemoryRepositoryNamespace , string $ diskRepositoryNamespace , string $ httpRepositoryNamespace ) { $ repositoryName = rtrim ( "apisearch.{$prefix}_repository_$appName.$indexName" , '.' ) ; $ tokenUUIDName = rtrim ( "apisearch.token_uuid.$appName" ) ; $ clientName = rtrim ( "apisearch.client_$appName" , '.' ) ; $ tokenUUIDReference = $ container -> register ( $ tokenUUIDName , TokenUUID :: class ) ; $ tokenUUIDReference -> setFactory ( [ TokenUUID :: class , 'createById' , ] ) -> addArgument ( ( string ) $ repositoryConfiguration [ 'token' ] ) -> setPrivate ( true ) ; $ repositoryReferenceName = rtrim ( "apisearch.repository_reference.$appName.$indexName" , '.' ) ; $ repositoryReferenceReference = new Reference ( $ repositoryReferenceName ) ; switch ( $ repositoryConfiguration [ 'adapter' ] ) { case 'in_memory' : $ container -> register ( $ repositoryName , $ inMemoryRepositoryNamespace ) -> addMethodCall ( 'setRepositoryReference' , [ $ repositoryReferenceReference , ] ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; break ; case 'disk' : $ container -> register ( $ repositoryName , $ diskRepositoryNamespace ) -> addMethodCall ( 'setRepositoryReference' , [ $ repositoryReferenceReference , ] ) -> addArgument ( $ repositoryConfiguration [ 'disk_file' ] . '.' . $ prefix . '.' . $ appName ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; break ; case 'http' : case 'http_test' : $ container -> register ( $ repositoryName , $ httpRepositoryNamespace ) -> addArgument ( new Reference ( $ clientName ) ) -> addMethodCall ( 'setCredentials' , [ $ repositoryReferenceReference , new Reference ( $ tokenUUIDName ) , ] ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; break ; case 'service' : $ repoDefinition = $ container -> getDefinition ( $ repositoryConfiguration [ $ prefix ] [ 'repository_service' ] ) ; $ this -> injectRepositoryCredentials ( $ repoDefinition , $ appName , $ repositoryConfiguration , $ indexName ) ; $ container -> setAlias ( $ repositoryName , $ repositoryConfiguration [ $ prefix ] [ 'repository_service' ] ) ; $ aliasDefinition = $ container -> getAlias ( $ repositoryName ) ; $ aliasDefinition -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; } $ container -> getDefinition ( "apisearch.{$prefix}_repository_bucket" ) -> addMethodCall ( 'addRepository' , [ $ appName , new Reference ( $ repositoryName ) ] ) -> setPublic ( $ this -> repositoryIsTest ( $ repositoryConfiguration ) ) ; }
Create standard repository.

@param ContainerBuilder $container
@param string           $appName
@param array            $repositoryConfiguration
@param string           $indexName
@param string           $prefix
@param string           $inMemoryRepositoryNamespace
@param string           $diskRepositoryNamespace
@param string           $httpRepositoryNamespace
Create standard repository .