本文整理匯總了PHP中Symfony\Component\DependencyInjection\DefinitionDecorator::replaceArgument方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefinitionDecorator::replaceArgument方法的具體用法?PHP DefinitionDecorator::replaceArgument怎麽用?PHP DefinitionDecorator::replaceArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\DefinitionDecorator
的用法示例。
在下文中一共展示了DefinitionDecorator::replaceArgument方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createConverter
private function createConverter($name, array $config, ContainerBuilder $container)
{
$environment = new DefinitionDecorator($config['environment']);
$environment->setPublic(false);
$environment->setClass($container->getDefinition($config['environment'])->getClass());
$environment->addMethodCall('mergeConfig', [$config['config']]);
$environment->addTag('webuni_commonmark.environment.extensions', $config['extensions']);
// $environment->addTag('webuni_commonmark.environment', ['parent' => $config['environment'], 'extensions' => [$config['extensions']]);
$environmentName = 'webuni_commonmark.' . $name . '_environment' . $config['environment'];
$container->setDefinition($environmentName, $environment);
$parser = new DefinitionDecorator($config['parser']);
$parser->setPublic(false);
$parser->setClass($container->getDefinition($config['parser'])->getClass());
$parser->replaceArgument(0, new Reference($environmentName));
$renderer = new DefinitionDecorator($config['renderer']);
$renderer->setPublic(false);
$renderer->setClass($container->getDefinition($config['renderer'])->getClass());
$renderer->replaceArgument(0, new Reference($environmentName));
$converter = new DefinitionDecorator($config['converter']);
$converter->setPublic(true);
$converter->setClass($container->getDefinition($config['converter'])->getClass());
$converter->replaceArgument(0, $parser);
$converter->replaceArgument(1, $renderer);
$converterName = 'webuni_commonmark.' . $name . '_converter';
$container->setDefinition($converterName, $converter);
return $converterName;
}
示例2: create
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $resolverName, array $config)
{
$awsS3ClientId = 'liip_imagine.cache.resolver.'.$resolverName.'.client';
$awsS3ClientDefinition = new Definition('Aws\S3\S3Client');
if (method_exists($awsS3ClientDefinition, 'setFactory')) {
$awsS3ClientDefinition->setFactory(array('Aws\S3\S3Client', 'factory'));
} else {
// to be removed when dependency on Symfony DependencyInjection is bumped to 2.6
$awsS3ClientDefinition->setFactoryClass('Aws\S3\S3Client');
$awsS3ClientDefinition->setFactoryMethod('factory');
}
$awsS3ClientDefinition->addArgument($config['client_config']);
$container->setDefinition($awsS3ClientId, $awsS3ClientDefinition);
$resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.aws_s3');
$resolverDefinition->replaceArgument(0, new Reference($awsS3ClientId));
$resolverDefinition->replaceArgument(1, $config['bucket']);
$resolverDefinition->replaceArgument(2, $config['acl']);
$resolverDefinition->replaceArgument(3, array_replace($config['url_options'], $config['get_options']));
$resolverDefinition->replaceArgument(4, $config['put_options']);
$resolverId = 'liip_imagine.cache.resolver.'.$resolverName;
$container->setDefinition($resolverId, $resolverDefinition);
if (isset($config['cache_prefix'])) {
$resolverDefinition->addMethodCall('setCachePrefix', array($config['cache_prefix']));
}
if ($config['proxies']) {
$proxiedResolverId = 'liip_imagine.cache.resolver.'.$resolverName.'.proxied';
$container->setDefinition($proxiedResolverId, $resolverDefinition);
$proxyResolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.proxy');
$proxyResolverDefinition->replaceArgument(0, new Reference($proxiedResolverId));
$proxyResolverDefinition->replaceArgument(1, $config['proxies']);
$container->setDefinition($resolverId, $proxyResolverDefinition);
}
if ($config['cache']) {
$cachedResolverId = 'liip_imagine.cache.resolver.'.$resolverName.'.cached';
$container->setDefinition($cachedResolverId, $container->getDefinition($resolverId));
$cacheResolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.cache');
$cacheResolverDefinition->replaceArgument(0, new Reference($config['cache']));
$cacheResolverDefinition->replaceArgument(1, new Reference($cachedResolverId));
$container->setDefinition($resolverId, $cacheResolverDefinition);
}
$container->getDefinition($resolverId)->addTag('liip_imagine.cache.resolver', array(
'resolver' => $resolverName,
));
return $resolverId;
}
示例3: addApis
/**
* {@inheritDoc}
*/
protected function addApis(Definition $paymentDefinition, ContainerBuilder $container, $contextName, array $config)
{
$publishableKey = new DefinitionDecorator('payum.stripe.keys.prototype');
$publishableKey->replaceArgument(0, $config['publishable_key']);
$publishableKey->replaceArgument(1, $config['secret_key']);
$publishableKey->setPublic(true);
$publishableKeyId = 'payum.context.' . $contextName . '.keys';
$container->setDefinition($publishableKeyId, $publishableKey);
$paymentDefinition->addMethodCall('addApi', array(new Reference($publishableKeyId)));
}
示例4: createListener
protected function createListener(ContainerBuilder $container, $id, $config, $userProvider)
{
$listenerId = 'security.authentication.listener.form';
$listener = new DefinitionDecorator($listenerId);
$listener->replaceArgument(4, $id);
$listener->replaceArgument(5, $config);
$listenerId .= '.' . $id;
$container->setDefinition($listenerId, $listener);
return $listenerId;
}
示例5: create
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $loaderName, array $config)
{
$loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.stream');
$loaderDefinition->replaceArgument(0, $config['wrapper']);
$loaderDefinition->replaceArgument(1, $config['context']);
$loaderDefinition->addTag('liip_imagine.binary.loader', array('loader' => $loaderName));
$loaderId = 'liip_imagine.binary.loader.' . $loaderName;
$container->setDefinition($loaderId, $loaderDefinition);
return $loaderId;
}
示例6: create
/**
* {@inheritdoc}
*/
public function create(ContainerBuilder $container, $resolverName, array $config)
{
$resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.web_path');
$resolverDefinition->replaceArgument(2, $config['web_root']);
$resolverDefinition->replaceArgument(3, $config['cache_prefix']);
$resolverDefinition->addTag('liip_imagine.cache.resolver', array('resolver' => $resolverName));
$resolverId = 'liip_imagine.cache.resolver.' . $resolverName;
$container->setDefinition($resolverId, $resolverDefinition);
return $resolverId;
}
示例7: addApis
/**
* {@inheritDoc}
*/
protected function addApis(Definition $paymentDefinition, ContainerBuilder $container, $contextName, array $config)
{
$apiDefinition = new DefinitionDecorator('payum.authorize_net_aim.api.prototype');
$apiDefinition->replaceArgument(0, $config['login_id']);
$apiDefinition->replaceArgument(1, $config['transaction_key']);
$apiDefinition->addMethodCall('setSandbox', array($config['sandbox']));
$apiId = 'payum.context.' . $contextName . '.api';
$container->setDefinition($apiId, $apiDefinition);
$paymentDefinition->addMethodCall('addApi', array(new Reference($apiId)));
}
示例8: createStorage
/**
* {@inheritdoc}
*/
protected function createStorage(ContainerBuilder $container, $modelClass, array $config)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config/storage'));
$loader->load('filesystem.xml');
$storage = new DefinitionDecorator('payum.storage.filesystem.prototype');
$storage->setPublic(true);
$storage->replaceArgument(0, $config['storage_dir']);
$storage->replaceArgument(1, $modelClass);
$storage->replaceArgument(2, $config['id_property']);
return $storage;
}
示例9: create
/**
* {@inheritdoc}
*/
public function create(ContainerBuilder $container, $resolverName, array $config)
{
$resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.flysystem');
$resolverDefinition->replaceArgument(0, new Reference($config['filesystem_service']));
$resolverDefinition->replaceArgument(2, $config['root_url']);
$resolverDefinition->replaceArgument(3, $config['cache_prefix']);
$resolverDefinition->addTag('liip_imagine.cache.resolver', array('resolver' => $resolverName));
$resolverId = 'liip_imagine.cache.resolver.' . $resolverName;
$container->setDefinition($resolverId, $resolverDefinition);
return $resolverId;
}
示例10: createListener
protected function createListener($container, $id, $config, $userProvider)
{
$listenerId = $this->getListenerId();
$listener = new DefinitionDecorator($listenerId);
$listener->replaceArgument(4, $id);
$listener->replaceArgument(5, new Reference($this->createAuthenticationSuccessHandler($container, $id, $config)));
$listener->replaceArgument(6, new Reference($this->createAuthenticationFailureHandler($container, $id, $config)));
$listener->replaceArgument(8, array_intersect_key($config, $this->options));
$listenerId .= '.' . $id;
$container->setDefinition($listenerId, $listener);
return $listenerId;
}
示例11: createListener
protected function createListener($container, $id, $config, $userProvider, $entryPoint)
{
$listenerId = 'security.authentication.listener.shibboleth';
$listener = new DefinitionDecorator($listenerId);
$listener->replaceArgument(3, $id);
if ($entryPoint) {
$listener->replaceArgument(4, new Reference($entryPoint));
}
$listenerId .= '.' . $id;
$container->setDefinition($listenerId, $listener);
return $listenerId;
}
示例12: process
/**
* @inheritdoc
*/
public function process(ContainerBuilder $container)
{
$definitions = array();
$servicesIds = $container->findTaggedServiceIds('pmd_state_machine.token_configurable');
foreach ($servicesIds as $serviceId => $tag) {
$group = isset($tag[0]['group']) ? $tag[0]['group'] : null;
$type = isset($tag[0]['type']) ? $tag[0]['type'] : null;
if (!isset($group) || !isset($type)) {
throw new \InvalidArgumentException(sprintf('Services tagged %s must have group and type defined', 'pmd_state_machine.token_configurable'));
}
$serviceDefinition = $container->getDefinition($serviceId);
$optionsId = sprintf('pmd_state_machine.behavior.%s_%s_options', $group, $type);
$optionsReference = new Reference($optionsId, ContainerInterface::NULL_ON_INVALID_REFERENCE);
// Configure options resolver
$resolverId = sprintf('pmd_state_machine.behavior.%s_%s_resolver', $group, $type);
$resolverReference = new Reference($resolverId);
$resolverDefinition = new DefinitionDecorator('pmd_state_machine.behavior_resolver.token_options_resolver');
$resolverDefinition->replaceArgument(0, $optionsReference);
// Configure configurable decorator
$configId = sprintf('pmd_state_machine.behavior.%s_%s_configurator', $group, $type);
$configDefinition = new DefinitionDecorator('pmd_state_machine.behavior.token_configurable_configurator');
$configDefinition->replaceArgument(0, $resolverReference);
$serviceDefinition->setConfigurator(array(new Reference($configId, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false), 'configure'));
$definitions[$resolverId] = $resolverDefinition;
$definitions[$configId] = $configDefinition;
}
$container->addDefinitions($definitions);
}
示例13: process
/**
* @param ContainerBuilder $container
*
* @throws \InvalidArgumentException
*/
public function process(ContainerBuilder $container)
{
$config = $container->getExtensionConfig('elastica')[0];
$jsonLdFrameLoader = $container->get('nemrod.elastica.jsonld.frame.loader.filesystem');
$confManager = $container->getDefinition('nemrod.elastica.config_manager');
$filiationBuilder = $container->get('nemrod.filiation.builder');
$jsonLdFrameLoader->setFiliationBuilder($filiationBuilder);
foreach ($config['indexes'] as $name => $index) {
$indexName = isset($index['index_name']) ? $index['index_name'] : $name;
foreach ($index['types'] as $typeName => $settings) {
$jsonLdFrameLoader->setEsIndex($name);
$frame = $jsonLdFrameLoader->load($settings['frame'], null, true, true, true);
$type = !empty($frame['@type']) ? $frame['@type'] : $settings['type'];
if (empty($type)) {
throw \Exception("You must provide a RDF Type.");
}
//type
$typeId = 'nemrod.elastica.type.' . $name . '.' . $typeName;
$indexId = 'nemrod.elastica.index.' . $name;
$typeDef = new DefinitionDecorator('nemrod.elastica.type.abstract');
$typeDef->replaceArgument(0, $type);
$typeDef->setFactory(array(new Reference($indexId), 'getType'));
$typeDef->addTag('nemrod.elastica.type', array('index' => $name, 'name' => $typeName, 'type' => $type));
$container->setDefinition($typeId, $typeDef);
//registering config to configManager
$confManager->addMethodCall('setTypeConfigurationArray', array($name, $typeName, $type, $frame));
}
}
}
示例14: process
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->findTaggedServiceIds('payum.storage_extension') as $id => $tagAttributes) {
foreach ($tagAttributes as $attributes) {
$paymentIds = array();
if (isset($attributes['all']) && $attributes['all']) {
$paymentIds = array_merge($paymentIds, $this->findAllPaymentIds($container));
}
if (isset($attributes['factory']) && $attributes['factory']) {
$paymentIds = array_merge($paymentIds, $this->findPaymentIdsByFactory($container, $attributes['factory']));
}
if (isset($attributes['context']) && $attributes['context']) {
$paymentIds = array_merge($paymentIds, $this->findPaymentIdsByContext($container, $attributes['context']));
}
$paymentIds = array_filter(array_unique($paymentIds));
foreach ($paymentIds as $paymentId) {
$storageExtension = new DefinitionDecorator('payum.extension.storage.prototype');
$storageExtension->replaceArgument(0, new Reference($id));
$storageExtension->setPublic(false);
if (false !== strpos($id, '.storage.')) {
$storageExtensionId = str_replace('.storage.', '.extension.storage.', $id);
} else {
throw new LogicException(sprintf('In order to add storage to extension the storage %id has to contains ".storage." inside.', $id));
}
$container->setDefinition($storageExtensionId, $storageExtension);
$payment = $container->getDefinition($paymentId);
$payment->addMethodCall('addExtension', array(new Reference($storageExtensionId), isset($attributes['prepend']) && $attributes['prepend']));
}
}
}
}
示例15: process
/**
* @inheritdoc
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('qimnet.crud.configuration.repository')) {
return;
}
$repository = $container->getDefinition('qimnet.crud.configuration.repository');
$defaults = $container->getParameter('qimnet.crud.defaults');
foreach ($container->getParameter('qimnet.crud.services') as $name => $configuration) {
$options = $configuration['options'] + array('name' => $name) + $defaults['options'];
$configuration = $configuration + $defaults;
$serviceId = 'qimnet.crud.configuration.' . strtolower($name);
$definition = new DefinitionDecorator('qimnet.crud.configuration');
foreach (array('object_manager_factory', 'security_context_factory', 'path_generator_factory') as $index => $key) {
if ($configuration[$key]) {
$definition->replaceArgument($index, new Reference($configuration[$key]));
}
}
$definition->addArgument($options);
if ($configuration['class']) {
$definition->setClass($configuration['class']);
}
$definition->addTag('qimnet.crud.configuration', array('alias' => $name, 'object_class' => $options['object_class'], 'worker' => $configuration['worker'], 'redirection_manager' => $configuration['redirection_manager']));
$container->setDefinition($serviceId, $definition);
}
$taggedServices = $container->findTaggedServiceIds('qimnet.crud.configuration');
foreach ($taggedServices as $id => $attributes) {
$repository->addMethodCall('add', array($attributes[0]['alias'], $attributes[0]['object_class'], $id, $attributes[0]['worker'], $attributes[0]['redirection_manager']));
}
}