src/DependencyInjection/SonataMediaExtension.php
public function configureCdnAdapter(ContainerBuilder $container, array $config)
    {
        // add the default configuration for the server cdn
        if ($container->hasDefinition('sonata.media.cdn.server') && isset($config['cdn']['server'])) {
            $container->getDefinition('sonata.media.cdn.server')
                ->replaceArgument(0, $config['cdn']['server']['path'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.server');
        }

        if ($container->hasDefinition('sonata.media.cdn.panther') && isset($config['cdn']['panther'])) {
            $container->getDefinition('sonata.media.cdn.panther')
                ->replaceArgument(0, $config['cdn']['panther']['path'])
                ->replaceArgument(1, $config['cdn']['panther']['username'])
                ->replaceArgument(2, $config['cdn']['panther']['password'])
                ->replaceArgument(3, $config['cdn']['panther']['site_id'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.panther');
        }

        if ($container->hasDefinition('sonata.media.cdn.cloudfront') && isset($config['cdn']['cloudfront'])) {
            $container->getDefinition('sonata.media.cdn.cloudfront')
                ->replaceArgument(0, $config['cdn']['cloudfront']['path'])
                ->replaceArgument(1, $config['cdn']['cloudfront']['key'])
                ->replaceArgument(2, $config['cdn']['cloudfront']['secret'])
                ->replaceArgument(3, $config['cdn']['cloudfront']['distribution_id'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.cloudfront');
        }

        if ($container->hasDefinition('sonata.media.cdn.fallback') && isset($config['cdn']['fallback'])) {
            $container->getDefinition('sonata.media.cdn.fallback')
                ->replaceArgument(0, new Reference($config['cdn']['fallback']['master']))
                ->replaceArgument(1, new Reference($config['cdn']['fallback']['fallback']))
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.fallback');
        }
    }
public function configureCdnAdapter(ContainerBuilder $container, array $config)
    {
        // add the default configuration for the server cdn
        if ($container->hasDefinition('sonata.media.cdn.server') && isset($config['cdn']['server'])) {
            $container->getDefinition('sonata.media.cdn.server')
                ->replaceArgument(0, $config['cdn']['server']['path'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.server');
        }

        if ($container->hasDefinition('sonata.media.cdn.panther') && isset($config['cdn']['panther'])) {
            $container->getDefinition('sonata.media.cdn.panther')
                ->replaceArgument(0, $config['cdn']['panther']['path'])
                ->replaceArgument(1, $config['cdn']['panther']['username'])
                ->replaceArgument(2, $config['cdn']['panther']['password'])
                ->replaceArgument(3, $config['cdn']['panther']['site_id'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.panther');
        }

        if ($container->hasDefinition('sonata.media.cdn.cloudfront') && isset($config['cdn']['cloudfront'])) {
            $container->getDefinition('sonata.media.cdn.cloudfront')
                ->replaceArgument(0, $config['cdn']['cloudfront']['path'])
                ->replaceArgument(1, $config['cdn']['cloudfront']['key'])
                ->replaceArgument(2, $config['cdn']['cloudfront']['secret'])
                ->replaceArgument(3, $config['cdn']['cloudfront']['distribution_id'])
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.cloudfront');
        }

        if ($container->hasDefinition('sonata.media.cdn.fallback') && isset($config['cdn']['fallback'])) {
            $container->getDefinition('sonata.media.cdn.fallback')
                ->replaceArgument(0, new Reference($config['cdn']['fallback']['master']))
                ->replaceArgument(1, new Reference($config['cdn']['fallback']['fallback']))
            ;
        } else {
            $container->removeDefinition('sonata.media.cdn.fallback');
        }
    }
public function configureCdnAdapter ( ContainerBuilder $ container , array $ config ) { // add the default configuration for the server cdn if ( $ container -> hasDefinition ( 'sonata.media.cdn.server' ) && isset ( $ config [ 'cdn' ] [ 'server' ] ) ) { $ container -> getDefinition ( 'sonata.media.cdn.server' ) -> replaceArgument ( 0 , $ config [ 'cdn' ] [ 'server' ] [ 'path' ] ) ; } else { $ container -> removeDefinition ( 'sonata.media.cdn.server' ) ; } if ( $ container -> hasDefinition ( 'sonata.media.cdn.panther' ) && isset ( $ config [ 'cdn' ] [ 'panther' ] ) ) { $ container -> getDefinition ( 'sonata.media.cdn.panther' ) -> replaceArgument ( 0 , $ config [ 'cdn' ] [ 'panther' ] [ 'path' ] ) -> replaceArgument ( 1 , $ config [ 'cdn' ] [ 'panther' ] [ 'username' ] ) -> replaceArgument ( 2 , $ config [ 'cdn' ] [ 'panther' ] [ 'password' ] ) -> replaceArgument ( 3 , $ config [ 'cdn' ] [ 'panther' ] [ 'site_id' ] ) ; } else { $ container -> removeDefinition ( 'sonata.media.cdn.panther' ) ; } if ( $ container -> hasDefinition ( 'sonata.media.cdn.cloudfront' ) && isset ( $ config [ 'cdn' ] [ 'cloudfront' ] ) ) { $ container -> getDefinition ( 'sonata.media.cdn.cloudfront' ) -> replaceArgument ( 0 , $ config [ 'cdn' ] [ 'cloudfront' ] [ 'path' ] ) -> replaceArgument ( 1 , $ config [ 'cdn' ] [ 'cloudfront' ] [ 'key' ] ) -> replaceArgument ( 2 , $ config [ 'cdn' ] [ 'cloudfront' ] [ 'secret' ] ) -> replaceArgument ( 3 , $ config [ 'cdn' ] [ 'cloudfront' ] [ 'distribution_id' ] ) ; } else { $ container -> removeDefinition ( 'sonata.media.cdn.cloudfront' ) ; } if ( $ container -> hasDefinition ( 'sonata.media.cdn.fallback' ) && isset ( $ config [ 'cdn' ] [ 'fallback' ] ) ) { $ container -> getDefinition ( 'sonata.media.cdn.fallback' ) -> replaceArgument ( 0 , new Reference ( $ config [ 'cdn' ] [ 'fallback' ] [ 'master' ] ) ) -> replaceArgument ( 1 , new Reference ( $ config [ 'cdn' ] [ 'fallback' ] [ 'fallback' ] ) ) ; } else { $ container -> removeDefinition ( 'sonata.media.cdn.fallback' ) ; } }
Inject CDN dependency to default provider.

@param ContainerBuilder $container
@param array            $config
Inject CDN dependency to default provider .