当前位置: 首页>>代码示例>>PHP>>正文


PHP DependencyInjection\ContainerBuilder类代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder类的具体用法?PHP ContainerBuilder怎么用?PHP ContainerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ContainerBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * Processes the ContainerBuilder to resolve parameter placeholders.
  *
  * @param ContainerBuilder $container
  *
  * @throws ParameterNotFoundException
  */
 public function process(ContainerBuilder $container)
 {
     $parameterBag = $container->getParameterBag();
     foreach ($container->getDefinitions() as $id => $definition) {
         try {
             $definition->setClass($parameterBag->resolveValue($definition->getClass()));
             $definition->setFile($parameterBag->resolveValue($definition->getFile()));
             $definition->setArguments($parameterBag->resolveValue($definition->getArguments()));
             if ($definition->getFactoryClass(false)) {
                 $definition->setFactoryClass($parameterBag->resolveValue($definition->getFactoryClass(false)));
             }
             $factory = $definition->getFactory();
             if (is_array($factory) && isset($factory[0])) {
                 $factory[0] = $parameterBag->resolveValue($factory[0]);
                 $definition->setFactory($factory);
             }
             $calls = array();
             foreach ($definition->getMethodCalls() as $name => $arguments) {
                 $calls[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($arguments);
             }
             $definition->setMethodCalls($calls);
             $definition->setProperties($parameterBag->resolveValue($definition->getProperties()));
         } catch (ParameterNotFoundException $e) {
             $e->setSourceId($id);
             throw $e;
         }
     }
     $aliases = array();
     foreach ($container->getAliases() as $name => $target) {
         $aliases[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($target);
     }
     $container->setAliases($aliases);
     $parameterBag->resolve();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:41,代码来源:ResolveParameterPlaceHoldersPass.php

示例2: build

 /**
  * {@inheritDoc}
  */
 public function build(ContainerBuilder $container)
 {
     /** @var  PayumExtension $payumExtension */
     $payumExtension = $container->getExtension('payum');
     $payumExtension->addGatewayFactory(new JmsGatewayFactory());
     $payumExtension->addGatewayFactory(new FooBarGatewayPaymentFactory());
 }
开发者ID:partkeepr,项目名称:PayumBundleSandbox,代码行数:10,代码来源:AcmeOtherExamplesBundle.php

示例3: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('twig');
     foreach ($container->findTaggedServiceIds('twig.token_parser') as $id => $attributes) {
         $definition->addMethodCall('addTokenParser', [new Reference($id)]);
     }
 }
开发者ID:Briareos,项目名称:Undine,代码行数:10,代码来源:TwigEnvironmentPass.php

示例4: prepend

 /**
  * Allow an extension to prepend the extension configurations.
  *
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  */
 public function prepend(ContainerBuilder $container)
 {
     $configFile = __DIR__ . '/../Resources/config/templates.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($configFile));
 }
开发者ID:eab-dev,项目名称:UniqueDatatypesBundle,代码行数:12,代码来源:EabUniqueDatatypesExtension.php

示例5: createEnvironment

 /**
  * @param ContainerBuilder $container
  * @param string           $code
  * @param Definition       $formatter
  * @param array            $extensions
  *
  * @return string
  */
 public function createEnvironment(ContainerBuilder $container, $code, Definition $formatter, array $extensions)
 {
     $loader = new Definition('Twig_Loader_String');
     $loader->setPublic(false);
     $container->setDefinition(sprintf('sonata.formatter.twig.loader.%s', $code), $loader);
     $loaderSelector = new Definition('Sonata\\FormatterBundle\\Twig\\Loader\\LoaderSelector', array(new Reference(sprintf('sonata.formatter.twig.loader.%s', $code)), new Reference('twig.loader')));
     $loaderSelector->setPublic(false);
     $env = new Definition('Twig_Environment', array($loaderSelector, array('debug' => false, 'strict_variables' => false, 'charset' => 'UTF-8')));
     $env->setPublic(false);
     $container->setDefinition(sprintf('sonata.formatter.twig.env.%s', $code), $env);
     $sandboxPolicy = new Definition('Sonata\\FormatterBundle\\Twig\\SecurityPolicyContainerAware', array(new Reference('service_container'), $extensions));
     $sandboxPolicy->setPublic(false);
     $container->setDefinition(sprintf('sonata.formatter.twig.sandbox.%s.policy', $code), $sandboxPolicy);
     $sandbox = new Definition('Twig_Extension_Sandbox', array($sandboxPolicy, true));
     $sandbox->setPublic(false);
     $container->setDefinition(sprintf('sonata.formatter.twig.sandbox.%s', $code), $sandbox);
     $env->addMethodCall('addExtension', array(new Reference(sprintf('sonata.formatter.twig.sandbox.%s', $code))));
     foreach ($extensions as $extension) {
         $env->addMethodCall('addExtension', array(new Reference($extension)));
     }
     $lexer = new Definition('Twig_Lexer', array(new Reference(sprintf('sonata.formatter.twig.env.%s', $code)), array('tag_comment' => array('<#', '#>'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<%=', '%>'))));
     $lexer->setPublic(false);
     $container->setDefinition(new Reference(sprintf('sonata.formatter.twig.lexer.%s', $code)), $lexer);
     $env->addMethodCall('setLexer', array(new Reference(sprintf('sonata.formatter.twig.lexer.%s', $code))));
     return sprintf('sonata.formatter.twig.env.%s', $code);
 }
开发者ID:devcodixis,项目名称:SonataFormatterBundle,代码行数:34,代码来源:SonataFormatterExtension.php

示例6: getConnectionReference

 /**
  * @param string                                                    $name
  * @param array                                                     $config
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder   $container
  *
  * @return \Symfony\Component\DependencyInjection\Reference
  */
 private function getConnectionReference($name, array $config, ContainerBuilder $container)
 {
     if (isset($config['connection_id'])) {
         return new Reference($config['connection_id']);
     }
     $host = $config['host'];
     $port = $config['port'];
     $connClass = '%doctrine_cache.redis.connection.class%';
     $connId = sprintf('doctrine_cache.services.%s_redis.connection', $name);
     $connDef = new Definition($connClass);
     $connParams = array($host, $port);
     if (isset($config['timeout'])) {
         $connParams[] = $config['timeout'];
     }
     $connDef->setPublic(false);
     $connDef->addMethodCall('connect', $connParams);
     if (isset($config['password'])) {
         $password = $config['password'];
         $connDef->addMethodCall('auth', array($password));
     }
     if (isset($config['database'])) {
         $database = (int) $config['database'];
         $connDef->addMethodCall('select', array($database));
     }
     $container->setDefinition($connId, $connDef);
     return new Reference($connId);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:34,代码来源:RedisDefinition.php

示例7: isIntegrationEnabled

 private function isIntegrationEnabled(ContainerBuilder $container)
 {
     if (!$container->hasParameter('riemann.integration.monolog')) {
         return false;
     }
     return true === $container->getParameter('riemann.integration.monolog');
 }
开发者ID:trademachines,项目名称:riemann-logging-bundle,代码行数:7,代码来源:MonologIntegrationPass.php

示例8: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $appConfig = $this->processConfiguration($configuration, $configs);
     $dashboardDefinition = $container->register('app.dashboard', 'AppBundle\\Dashboard\\Dashboard');
     $dashboardDefinition->addMethodCall('loadFromConfiguration', array($appConfig));
 }
开发者ID:symfony-tutorial,项目名称:app,代码行数:7,代码来源:AppExtension.php

示例9: changeService

 /**
  * @param ContainerBuilder $container
  * @param string $serviceName
  * @param string $newServiceName
  */
 private function changeService(ContainerBuilder $container, $serviceName, $newServiceName)
 {
     $service = $container->getDefinition($serviceName);
     $newService = $container->getDefinition($newServiceName);
     $container->removeDefinition($serviceName);
     $container->setDefinition($serviceName, $newService);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:12,代码来源:OverrideServiceCompilerPass.php

示例10: getUserProviders

 /**
  * @param ContainerBuilder $container
  * @param array            $config
  * @param string           $id
  * @param string           $rememberMeServicesId
  *
  * @return array
  */
 protected function getUserProviders(ContainerBuilder $container, $config, $id, $rememberMeServicesId)
 {
     $userProviders = [];
     foreach ($container->findTaggedServiceIds('security.remember_me_aware') as $serviceId => $attributes) {
         foreach ($attributes as $attribute) {
             if (!isset($attribute['id']) || $attribute['id'] !== $id) {
                 continue;
             }
             if (!isset($attribute['provider'])) {
                 throw new \RuntimeException('Each "security.remember_me_aware" tag must have a provider attribute.');
             }
             $userProviders[] = new Reference($attribute['provider']);
             $container->getDefinition($serviceId)->addMethodCall('setRememberMeServices', array(new Reference($rememberMeServicesId)));
         }
     }
     if ($config['user_providers']) {
         $userProviders = array();
         foreach ($config['user_providers'] as $providerName) {
             $userProviders[] = new Reference('security.user.provider.concrete.' . $providerName);
         }
     }
     if (count($userProviders) === 0) {
         throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login)
             for each firewall that has organization-remember-me enabled.');
     }
     return $userProviders;
 }
开发者ID:xamin123,项目名称:platform,代码行数:35,代码来源:OrganizationRememberMeFactory.php

示例11: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->findTaggedServiceIds('vlr.model.violation.handler') as $id => $tags) {
         $priority = isset($tags[0]) && isset($tags[0]['priority']) ? $tags[0]['priority'] : null;
         $container->getDefinition('rezzza.violation.handler.manager')->addMethodCall('add', array($container->getDefinition($id), $priority));
     }
 }
开发者ID:rezzza,项目名称:ModelViolationLoggerBundle,代码行数:10,代码来源:AddHandlersCompilerPass.php

示例12: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     if (isset($config['handler_path'])) {
         $container->setParameter('shibboleth.handler_path', $config['handler_path']);
     }
     if (isset($config['secured_handler'])) {
         $container->setParameter('shibboleth.secured_handler', $config['secured_handler']);
     }
     if (isset($config['session_initiator_path'])) {
         $container->setParameter('shibboleth.session_initiator_path', $config['session_initiator_path']);
     }
     if (isset($config['username_attribute'])) {
         $container->setParameter('shibboleth.username_attribute', $config['username_attribute']);
     }
     if (isset($config['attribute_definitions'])) {
         $container->setParameter('shibboleth.attribute_definitions', $config['attribute_definitions']);
     } else {
         $container->setParameter('shibboleth.attribute_definitions', array());
     }
     if (isset($config['use_headers'])) {
         $container->setParameter('shibboleth.use_headers', $config['use_headers']);
     } else {
         $container->setParameter('shibboleth.use_headers', true);
     }
     if (isset($config['logout_target'])) {
         $container->setParameter('shibboleth.logout_target', $config['logout_target']);
     }
 }
开发者ID:roenschg,项目名称:ShibbolethBundle,代码行数:35,代码来源:ShibbolethExtension.php

示例13: prepend

 /**
  * {@inheritdoc}
  */
 public function prepend(ContainerBuilder $container)
 {
     if (!$container->hasExtension('sylius_order')) {
         throw new \RuntimeException('Please install and configure SyliusOrderBundle in order to use SyliusCartBundle.');
     }
     $container->prependExtensionConfig('sylius_order', array('resources' => array('order' => array('classes' => array('model' => Cart::class)), 'order_item' => array('classes' => array('model' => CartItem::class)))));
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:10,代码来源:SyliusCartExtension.php

示例14: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $coordinator = $container->getDefinition('sylius.process.coordinator');
     foreach ($container->findTaggedServiceIds('sylius.process.scenario') as $id => $attributes) {
         $coordinator->addMethodCall('registerScenario', array($attributes[0]['alias'], new Reference($id)));
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:RegisterScenariosPass.php

示例15: setParameterSection

 public function setParameterSection(ContainerBuilder $container, $page, array $captchaConfig)
 {
     $container->setParameter('captcha.config.' . $page, $captchaConfig);
     $container->setParameter('captcha.config.' . $page . '.captcha_id', $captchaConfig['captcha_id']);
     $container->setParameter('captcha.config.' . $page . '.user_input_id', $captchaConfig['user_input_id']);
     $container->setParameter('captcha.config.' . $page . '.captcha_config_file_path', $captchaConfig['captcha_config_file_path']);
 }
开发者ID:RubenCox,项目名称:Symfony_Web-Mobile,代码行数:7,代码来源:CaptchaExtension.php


注:本文中的Symfony\Component\DependencyInjection\ContainerBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。