當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DefinitionDecorator::setFactoryMethod方法代碼示例

本文整理匯總了PHP中Symfony\Component\DependencyInjection\DefinitionDecorator::setFactoryMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefinitionDecorator::setFactoryMethod方法的具體用法?PHP DefinitionDecorator::setFactoryMethod怎麽用?PHP DefinitionDecorator::setFactoryMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DependencyInjection\DefinitionDecorator的用法示例。


在下文中一共展示了DefinitionDecorator::setFactoryMethod方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     foreach ($config['connections'] as $name => $values) {
         $def = new Definition();
         $def->setClass($container->getParameter('agentsib_sphinx.connection.class'));
         $params = array('host' => $values['host'], 'port' => $values['port']);
         if ($values['socket']) {
             $params['socket'] = $values['socket'];
         }
         $def->setArguments(array($name, $values['driver'], $params));
         $def->addMethodCall('addLogger', array(new Reference('agentsib_sphinx.logger')));
         $container->setDefinition(sprintf('agentsib_sphinx.%s.connection', $name), $def);
         $helperDef = new DefinitionDecorator('agentsib_sphinx.factory.helper');
         $helperDef->setFactoryClass($container->getParameter('agentsib_sphinx.helper.class'));
         $helperDef->setFactoryMethod('create');
         $helperDef->addArgument(new Reference(sprintf('agentsib_sphinx.%s.connection', $name)));
         $helperDef->setPublic(true);
         $container->setDefinition(sprintf('agentsib_sphinx.%s.helper', $name), $helperDef);
         if ($name == $config['default_connection']) {
             $container->setAlias('agentsib_sphinx.connection', sprintf('agentsib_sphinx.%s.connection', $name));
             $container->setAlias('agentsib_sphinx.helper', sprintf('agentsib_sphinx.%s.helper', $name));
         }
     }
 }
開發者ID:agentsib,項目名稱:sphinx-bundle,代碼行數:31,代碼來源:AgentSIBSphinxExtension.php

示例2: registerExecutorConfiguration

 /**
  * @param array            $config
  * @param ContainerBuilder $container
  * @param LoaderInterface  $loader
  */
 private function registerExecutorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader)
 {
     $loader->load('executor.xml');
     $defaultExecutor = isset($config['default']) ? $config['default'] : null;
     foreach ($config['executorList'] as $name => $executorConf) {
         $def = new DefinitionDecorator($executorConf['parent_service']);
         $def->replaceArgument(0, $executorConf['server'])->replaceArgument(1, $executorConf['request_handler'])->replaceArgument(2, new Reference($executorConf['exception_handler_service']))->addTag(AddExecutorPass::TAG_NAME, array('default' => $name == $defaultExecutor, 'alias' => $name));
         if (!empty($executorConf['use_factory'])) {
             $def->setFactoryService(new Reference('syrma.web_container.executor.factory'));
             $def->setFactoryMethod('create');
         }
         $container->setDefinition(sprintf('syrma.web_container.executor.dynamic.%s', $name), $def);
     }
 }
開發者ID:syrma-php,項目名稱:web-container-bundle,代碼行數:19,代碼來源:SyrmaWebContainerExtension.php


注:本文中的Symfony\Component\DependencyInjection\DefinitionDecorator::setFactoryMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。