本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::camelize方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::camelize方法的具体用法?PHP ContainerBuilder::camelize怎么用?PHP ContainerBuilder::camelize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::camelize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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['actions'] as $key => $value) {
if ($value['max_number_by_ip']) {
$definition = new Definition('Kunstmaan\\VotingBundle\\EventListener\\Security\\MaxNumberByIpEventListener');
$definition->addArgument(new Reference('kunstmaan_voting.services.repository_resolver'));
$definition->addArgument($value['max_number_by_ip']);
$definition->addTag('kernel.event_listener', array('event' => 'kunstmaan_voting.' . lcfirst(ContainerBuilder::camelize($key)), 'method' => 'onVote', 'priority' => 100));
$container->setDefinition('kunstmaan_voting.security.' . $key . '.max_number_by_ip_event_listener', $definition);
}
}
$possibleActions = array('up_vote', 'down_vote', 'facebook_like', 'facebook_send', 'linkedin_share');
$votingDefaultValue = $config['voting_default_value'];
// If the user overwrites the voting_default_value in paramters file, we use this one
if ($container->hasParameter('voting_default_value')) {
$votingDefaultValue = $container->getParameter('voting_default_value');
}
// When no values are defined, initialize with defaults
foreach ($possibleActions as $action) {
if (!isset($config['actions'][$action]) || !is_array($config['actions'][$action])) {
$config['actions'][$action]['default_value'] = $action == 'down_vote' ? -1 * $votingDefaultValue : $votingDefaultValue;
}
}
$container->setParameter('kuma_voting.actions', $config['actions']);
}
示例2: loadAmqpTransport
private function loadAmqpTransport(array $config, ContainerBuilder $container)
{
$this->loader->load('transport/amqp/amqp.xml');
$this->loader->load(sprintf('transport/amqp/%s.xml', $config['driver']));
if (class_exists('JMS\\AopBundle\\JMSAopBundle')) {
$this->loader->load('transport/amqp/tracer.xml');
}
$camelizeKey = function (array $config) {
$camelized = [];
foreach ($config as $key => $value) {
$camelized[lcfirst(ContainerBuilder::camelize($key))] = $value;
}
return $camelized;
};
$definitions = [];
foreach ($config['connections'] as $name => $connectionConfig) {
$exchanges = $connectionConfig['exchanges'];
unset($connectionConfig['exchanges']);
$queues = $connectionConfig['queues'];
unset($connectionConfig['queues']);
$amqp = new DefinitionDecorator('event_band.transport.amqp.definition');
$amqp->addMethodCall('connection', [$camelizeKey($connectionConfig)]);
foreach ($exchanges as $exchange => $exchangeConfig) {
$exchangeType = $exchangeConfig['type'];
unset($exchangeConfig['type']);
$amqp->addMethodCall($exchangeType . 'Exchange', [$exchange, $camelizeKey($exchangeConfig)]);
}
foreach ($queues as $queue => $queueConfig) {
$amqp->addMethodCall('queue', [$queue, $camelizeKey($queueConfig)]);
}
$definitionId = self::getTransportDefinitionId('amqp', $name);
$container->setDefinition($definitionId, $amqp);
$definitions[$name] = $definitionId;
$connection = new DefinitionDecorator('event_band.transport.amqp.connection_definition');
$connection->setFactoryService($definitionId);
$connectionId = self::getAmqpConnectionDefinitionId($name);
$container->setDefinition($connectionId, $connection);
$factory = new DefinitionDecorator(sprintf('event_band.transport.amqp.connection_factory.%s', $config['driver']));
$factory->addMethodCall('setDefinition', [new Reference($connectionId)]);
$container->setDefinition(self::getAmqpLibConnectionFactoryId($name), $factory);
$driver = new DefinitionDecorator('event_band.transport.amqp.driver.' . $config['driver']);
$driver->replaceArgument(0, new Reference($this->getAmqpLibConnectionFactoryId($name)));
$container->setDefinition($this->getAmqpDriverId($name), $driver);
$configurator = new DefinitionDecorator('event_band.transport.amqp.configurator');
$configurator->replaceArgument(0, new Reference($this->getAmqpDriverId($name)));
$container->setDefinition(self::getTypedTransportConfiguratorId('amqp', $name), $configurator);
$container->getDefinition(self::getTransportConfiguratorId())->addMethodCall('registerConfigurator', ['amqp.' . $name, new Reference(self::getTypedTransportConfiguratorId('amqp', $name))]);
}
$container->setParameter('event_band.transport_definitions', array_merge($container->getParameter('event_band.transport_definitions'), ['amqp' => $definitions]));
foreach ($config['converters'] as $name => $converterConfig) {
$definition = new DefinitionDecorator('event_band.transport.amqp.converter.serialize');
$definition->replaceArgument(0, new Reference(self::getSerializerId($converterConfig['parameters']['serializer'])));
$container->setDefinition(self::getAmqpConverterId($name), $definition);
}
}
示例3: load
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $configs);
foreach (array_keys($config) as $key) {
$container->setParameter('bitpay.' . $key, $config[$key]);
}
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
$loader->load('services.xml');
$container->setParameter('network.class', 'Bitpay\\Network\\' . ContainerBuilder::camelize($config['network']));
$container->setParameter('adapter.class', 'Bitpay\\Client\\Adapter\\' . ContainerBuilder::camelize($config['adapter']) . 'Adapter');
$container->setParameter('key_storage.class', $config['key_storage']);
}