本文整理匯總了PHP中Symfony\Component\DependencyInjection\DefinitionDecorator::setFactoryClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefinitionDecorator::setFactoryClass方法的具體用法?PHP DefinitionDecorator::setFactoryClass怎麽用?PHP DefinitionDecorator::setFactoryClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\DefinitionDecorator
的用法示例。
在下文中一共展示了DefinitionDecorator::setFactoryClass方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
}
}