本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::addAliases方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::addAliases方法的具体用法?PHP ContainerBuilder::addAliases怎么用?PHP ContainerBuilder::addAliases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::addAliases方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$config = $container->getParameter(ModeraActivityLoggerExtension::CONFIG_KEY);
$aliasConfig = array();
// alias : id
$aliasConfig['modera_activity_logger.manager.activity_manager'] = $config['activity_manager'];
$container->addAliases($aliasConfig);
}
示例2: process
public function process(ContainerBuilder $container)
{
if (false === $container->hasParameter('francodacosta.caparica.client.provider.id')) {
throw new InvalidConfigurationException("[Caparica] Missing client provider id");
}
$providerId = $container->getParameter('francodacosta.caparica.client.provider.id');
$container->addAliases(['francodacosta.caparica.client.provider' => $providerId]);
}
示例3: process
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
$appDefinition = $container->register('proto_kernel.app', Application::class);
$arguments = [null, null];
if ($container->hasParameter('app.name')) {
$arguments[0] = '%app.name%';
}
if ($container->hasParameter('app.version')) {
$arguments[1] = '%app.version%';
}
$appDefinition->setArguments($arguments);
$container->addAliases(['app' => 'proto_kernel.app']);
}
示例4: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$container->setAlias('kassko_class_resolver', new Alias('kassko_class_resolver.chain', true));
$containerAdapterDef = $container->getDefinition('kassko_class_resolver.container');
$containerAdapterDef->setClass($config['container_adapter_class']);
$container->addAliases($config['resolvers_aliases']);
if (isset($config['resolvers'])) {
foreach ($config['resolvers']['chain'] as $resolverConfig) {
$resolverDef = new DefinitionDecorator('kassko_class_resolver.chain');
foreach ($resolverConfig['nested_resolvers'] as $nestedResolverService) {
$resolverDef->addMethodCall('add', [new Reference($nestedResolverService)]);
}
if (null !== $resolverConfig['service']) {
$resolverDef->addMethodCall('setDefault', [new Reference($resolverConfig['service'])]);
} else {
$defaultResolverDef = new Definition($container->getParameter('kassko_class_resolver.default.class'), ['action' => $resolverConfig['on_not_found_class']['action']]);
$resolverDef->addMethodCall('setDefault', [$defaultResolverDef]);
}
$this->addAliasesByService($container, $config['resolver_aliases'], $resolverConfig['resolver_service']);
}
foreach ($config['resolvers']['container'] as $resolverConfig) {
$container->setDefinition($resolverConfig['resolver_service'], new DefinitionDecorator('kassko_class_resolver.container_aware'));
$this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
}
foreach ($config['resolvers']['map'] as $resolverConfig) {
foreach ($resolverConfig['items'] as $item) {
if ('@' !== substr($item['service'], 0, 1)) {
$item['service'] = new Reference($item['service']);
}
}
$resolverDef = new Definition($container->getParameter('kassko_class_resolver.map.class'), [$resolverConfig['items']]);
$container->setDefinition($resolverConfig['resolver_service'], $resolverDef);
$this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
}
foreach ($config['resolvers']['factory_adapter'] as $index => $resolverConfig) {
$resolverDef = new Definition($container->getParameter('kassko_class_resolver.factory_adapter.class'), [new Reference($resolverConfig['adapted_factory']), $resolverConfig['support_method'], $resolverConfig['resolve_method']]);
$container->setDefinition($resolverConfig['resolver_service'], $resolverDef);
$this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
}
foreach ($config['resolvers']['static_factory_adapter'] as $index => $resolverConfig) {
$resolverDef = new Definition($container->getParameter('kassko_class_resolver.static_factory_adapter.class'), [$resolverConfig['adapted_factory'], $resolverConfig['support_method'], $resolverConfig['resolve_method']]);
$container->setDefinition($resolverConfig['resolver_service'], $resolverDef);
$this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
}
}
}
示例5: process
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
$parameters = $container->getParameterBag()->all();
$definitions = $container->getDefinitions();
$aliases = $container->getAliases();
foreach ($container->getExtensions() as $name => $extension) {
$tmpContainer = new ContainerBuilder($container->getParameterBag());
$tmpContainer->addObjectResource($extension);
$extension->load($container->getExtensionConfig($name), $tmpContainer);
$container->merge($tmpContainer);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
$container->getParameterBag()->add($parameters);
}
示例6: load
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$config = $this->processConfiguration(new Configuration(), $configs);
$container->setParameter('pheat.manager.class', $config['manager']['class']);
$container->setParameter('pheat.context.class', $config['context']['class']);
$container->addAliases(['pheat.context' => $config['context']['service']]);
if (!empty($config['providers']['session'])) {
$loader->load('session.xml');
}
if (!empty($config['providers']['config'])) {
$loader->load('config.xml');
$container->getDefinition('pheat.provider.config')->setArguments([$config['features']]);
}
$loader->load('services.xml');
}
示例7: configureOptions
/**
* Configure optional settings
*
* @param $config
* @param ContainerBuilder $container
*/
protected function configureOptions(&$config, ContainerBuilder $container)
{
if ($config['enable_logging'] !== true) {
Logger::set(new NullLogger());
}
if (isset($config['router']['authentication']) && $config['router']['authentication'] !== false) {
//Inject the authentication manager into the router
$container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.authentication.manager')]);
}
if ($container->hasDefinition('security.user.provider.concrete.in_memory')) {
$container->addAliases(['in_memory_user_provider' => 'security.user.provider.concrete.in_memory']);
}
//Topic State Handler
if (isset($config['router']['enable_topic_state']) && $config['router']['enable_topic_state'] === true) {
$container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.topic.state.handler')]);
}
}
示例8: process
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
$parameters = $container->getParameterBag()->all();
$definitions = $container->getDefinitions();
$aliases = $container->getAliases();
foreach ($container->getExtensionConfigs() as $name => $configs) {
list($namespace, $tag) = explode(':', $name);
$extension = $container->getExtension($namespace);
$tmpContainer = new ContainerBuilder($container->getParameterBag());
$tmpContainer->addObjectResource($extension);
$extension->load($tag, $configs, $tmpContainer);
$container->merge($tmpContainer);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
$container->getParameterBag()->add($parameters);
}
示例9: process
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
$parameters = $container->getParameterBag()->all();
$definitions = $container->getDefinitions();
$aliases = $container->getAliases();
foreach ($container->getExtensions() as $name => $extension) {
if (!($config = $container->getExtensionConfig($name))) {
// this extension was not called
continue;
}
$config = $container->getParameterBag()->resolveValue($config);
$tmpContainer = new ContainerBuilder($container->getParameterBag());
$tmpContainer->addObjectResource($extension);
$extension->load($config, $tmpContainer);
$container->merge($tmpContainer);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
$container->getParameterBag()->add($parameters);
}
示例10: configureOptions
/**
* Configure optional settings
*
* @param $config
* @param ContainerBuilder $container
*/
protected function configureOptions(&$config, ContainerBuilder $container)
{
//Add optional Manager
if (isset($config['router']['enable_manager']) && $config['router']['enable_manager'] === true) {
//Replace the dummy manager with the client manager
$container->getDefinition('voryx.thruway.manager.client')->setClass('Thruway\\Manager\\ManagerClient');
//Inject the manager client into the router
$container->getDefinition('voryx.thruway.server')->addMethodCall('addTransportProvider', [new Reference('voryx.thruway.internal.manager')]);
}
if ($config['enable_logging'] !== true) {
Logger::set(new NullLogger());
}
if (isset($config['router']['authentication']) && $config['router']['authentication'] !== false) {
//Inject the authentication manager into the router
$container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.authentication.manager')]);
}
if ($container->hasDefinition('security.user.provider.concrete.in_memory')) {
$container->addAliases(['in_memory_user_provider' => 'security.user.provider.concrete.in_memory']);
}
//Topic State Handler
if (isset($config['router']['enable_topic_state']) && $config['router']['enable_topic_state'] === true) {
$container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.topic.state.handler')]);
}
}
示例11: testAddAliases
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::addAliases
*/
public function testAddAliases()
{
$builder = new ContainerBuilder();
$builder->setAliases(array('bar' => 'foo'));
$builder->addAliases(array('foobar' => 'foo'));
$aliases = $builder->getAliases();
$this->assertTrue(isset($aliases['bar']));
$this->assertTrue(isset($aliases['foobar']));
}
示例12: addAliases
public function addAliases(array $aliases)
{
return $this->delegate->addAliases($aliases);
}
示例13: testAddAliases
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::addAliases
*/
public function testAddAliases()
{
$builder = new ContainerBuilder();
$builder->setAliases(array('bar' => 'foo'));
$builder->addAliases(array('foobar' => 'foo'));
$this->assertEquals(array('bar' => 'foo', 'foobar' => 'foo'), $builder->getAliases(), '->getAliases() returns all service aliases');
}