本文整理匯總了PHP中Symfony\Component\DependencyInjection\DefinitionDecorator::addArgument方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefinitionDecorator::addArgument方法的具體用法?PHP DefinitionDecorator::addArgument怎麽用?PHP DefinitionDecorator::addArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\DefinitionDecorator
的用法示例。
在下文中一共展示了DefinitionDecorator::addArgument方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('doctrine')) {
$definition = new DefinitionDecorator('dag.form.type.object_to_identifier');
$definition->addArgument(new Reference('doctrine'));
$definition->addArgument('dag_entity_to_identifier');
$definition->addTag('form.type', array('alias' => 'dag_entity_to_identifier'));
$container->setDefinition('dag_entity_to_identifier', $definition);
}
if ($container->hasDefinition('doctrine_mongodb')) {
$definition = new DefinitionDecorator('dag.form.type.object_to_identifier');
$definition->addArgument(new Reference('doctrine_mongodb'));
$definition->addArgument('dag_document_to_identifier');
$definition->addTag('form.type', array('alias' => 'dag_document_to_identifier'));
$container->setDefinition('dag_document_to_identifier', $definition);
if (!$container->hasDefinition('dag_entity_to_identifier')) {
$container->setAlias('dag_entity_to_identifier', 'dag_document_to_identifier');
}
}
if ($container->hasDefinition('doctrine_phpcr')) {
$definition = new DefinitionDecorator('dag.form.type.object_to_identifier');
$definition->addArgument(new Reference('doctrine_phpcr'));
$definition->addArgument('dag_phpcr_document_to_identifier');
$definition->addTag('form.type', array('alias' => 'dag_phpcr_document_to_identifier'));
$container->setDefinition('dag_phpcr_document_to_identifier', $definition);
if (!$container->hasDefinition('dag_entity_to_identifier')) {
$container->setAlias('dag_entity_to_identifier', 'dag_phpcr_document_to_identifier');
}
}
}
示例2: testConstructorWithInheritance
public function testConstructorWithInheritance()
{
$container = $this->getContainer(array(), array(__DIR__ . '/../../Functional/Bundle/TestBundle/Inheritance'));
$container->set('foo', $foo = new \stdClass());
$container->set('bar', $bar = new \stdClass());
$this->process($container);
$this->assertTrue($container->hasDefinition('concrete_class'));
$this->assertTrue($container->hasDefinition('abstract_class'));
$def = new DefinitionDecorator('abstract_class');
$def->setClass('JMS\\DiExtraBundle\\Tests\\Functional\\Bundle\\TestBundle\\Inheritance\\ConcreteClass');
$def->addArgument(new Reference('foo'));
$def->addArgument(new Reference('bar'));
$this->assertEquals($def, $container->getDefinition('concrete_class'));
}
示例3: 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']));
}
}
示例4: 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));
}
}
}
示例5: registerWorkflowConfiguration
/**
* Loads the workflow configuration.
*
* @param array $workflows A workflow configuration array
* @param ContainerBuilder $container A ContainerBuilder instance
* @param XmlFileLoader $loader An XmlFileLoader instance
*/
private function registerWorkflowConfiguration(array $workflows, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$workflows) {
return;
}
$loader->load('workflow.xml');
$registryDefinition = $container->getDefinition('workflow.registry');
foreach ($workflows as $name => $workflow) {
$type = $workflow['type'];
$transitions = array();
foreach ($workflow['transitions'] as $transitionName => $transition) {
if ($type === 'workflow') {
$transitions[] = new Definition(Workflow\Transition::class, array($transitionName, $transition['from'], $transition['to']));
} elseif ($type === 'state_machine') {
foreach ($transition['from'] as $from) {
foreach ($transition['to'] as $to) {
$transitions[] = new Definition(Workflow\Transition::class, array($transitionName, $from, $to));
}
}
}
}
// Create a Definition
$definitionDefinition = new Definition(Workflow\Definition::class);
$definitionDefinition->setPublic(false);
$definitionDefinition->addArgument($workflow['places']);
$definitionDefinition->addArgument($transitions);
$definitionDefinition->addTag('workflow.definition', array('name' => $name, 'type' => $type, 'marking_store' => isset($workflow['marking_store']['type']) ? $workflow['marking_store']['type'] : null));
if (isset($workflow['initial_place'])) {
$definitionDefinition->addArgument($workflow['initial_place']);
}
// Create MarkingStore
if (isset($workflow['marking_store']['type'])) {
$parentDefinitionId = 'workflow.marking_store.' . $workflow['marking_store']['type'];
$markingStoreDefinition = new DefinitionDecorator($parentDefinitionId);
foreach ($workflow['marking_store']['arguments'] as $argument) {
$markingStoreDefinition->addArgument($argument);
}
// explicitly set parent class to decorated definition in order to fix inconsistent behavior for <=2.7
// see https://github.com/symfony/symfony/issues/17353 and https://github.com/symfony/symfony/pull/15096
$markingStoreDefinition->setClass($container->getDefinition($parentDefinitionId)->getClass());
} elseif (isset($workflow['marking_store']['service'])) {
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
}
// Create Workflow
$workflowDefinition = new DefinitionDecorator(sprintf('%s.abstract', $type));
$workflowDefinition->replaceArgument(0, $definitionDefinition);
if (isset($markingStoreDefinition)) {
$workflowDefinition->replaceArgument(1, $markingStoreDefinition);
}
$workflowDefinition->replaceArgument(3, $name);
// Store to container
$workflowId = sprintf('%s.%s', $type, $name);
$container->setDefinition($workflowId, $workflowDefinition);
$container->setDefinition(sprintf('%s.definition', $workflowId), $definitionDefinition);
// Add workflow to Registry
foreach ($workflow['supports'] as $supportedClass) {
$registryDefinition->addMethodCall('add', array(new Reference($workflowId), $supportedClass));
}
}
}
示例6: createAssetVersionStrategy
private function createAssetVersionStrategy($packageName, $versionStrategy)
{
$version = new DefinitionDecorator($this->namespaceService('asset.version_strategy'));
$version->addArgument($versionStrategy);
$versionId = $this->namespaceService("_package.{$packageName}.version_strategy_asset");
$this->container->setDefinition($versionId, $version);
return new Reference($versionId);
}
示例7: createClient
private function createClient($id, $config, ContainerBuilder $container)
{
$config['listen'] = 'localhost:' . $config['mysql_port'] . ':mysql41';
$def = new DefinitionDecorator('acts.sphinx_realtime.client.abstract');
$def->addArgument($id)->addArgument($config);
$container->setDefinition('acts.sphinx_realtime.client.' . $id, $def);
return new Reference('acts.sphinx_realtime.client.' . $id);
}
示例8: loadSelect2Types
private function loadSelect2Types(ContainerBuilder $container)
{
$serviceId = 'admingenerator.form.extensions.type.select2';
$select2types = array('choice', 'language', 'country', 'timezone', 'locale', 'entity', 'document', 'model', 'hidden');
foreach ($select2types as $type) {
$typeDef = new DefinitionDecorator($serviceId);
$typeDef->addArgument($type)->addTag('form.type', array('alias' => 's2a_select2_' . $type));
$container->setDefinition($serviceId . '.' . $type, $typeDef);
}
}
示例9: load
/** {@inheritdoc} */
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('error-handler-services.xml');
$container->setParameter('error_handler.stage', $config['stage']);
$container->setParameter('error_handler.root_dir', $config['root_dir']);
$shutdownSeverity = strtoupper($config['shutdown_severity']);
$container->setParameter('error_handler.shutdown_severity', $shutdownSeverity);
$baseErrorHandler = $container->getDefinition('base_error_handler');
$baseErrorHandler->replaceArgument(0, Severity::$SEVERITIES[$shutdownSeverity]);
$errorHandler = $container->getDefinition('error_handler');
foreach ($config['categories'] as $categoryName => $categoryConfiguration) {
if (empty($categoryConfiguration['handlers'])) {
continue;
}
foreach ($categoryConfiguration['handlers'] as $handlerName => $handlerConfiguration) {
$handlerClass = $container->getParameter(sprintf('error_handler.handler_%s.class', $handlerName));
$handlerId = sprintf('error_handler.handler.%s.%s', $categoryName, $handlerName);
$handlerDefinition = new DefinitionDecorator('error_handler.abstract.handler');
$handlerDefinition->setClass($handlerClass);
$handlerDefinition->setPublic(false);
$handlerDefinition->setLazy(true);
switch ($handlerName) {
case 'bugsnag':
$handlerDefinition->addArgument($handlerConfiguration['apiKey']);
if (isset($handlerConfiguration['endpoint'])) {
$handlerDefinition->addMethodCall('setEndpoint', array($handlerConfiguration['endpoint']));
}
if (isset($handlerConfiguration['useSSL'])) {
$handlerDefinition->addMethodCall('setUseSSL', array($handlerConfiguration['useSSL']));
}
break;
case 'raven':
$handlerDefinition->addArgument($handlerConfiguration['endpoint']);
break;
}
$container->setDefinition($handlerId, $handlerDefinition);
$errorHandler->addMethodCall('addHandler', array(new Reference($handlerId), array($categoryName)));
}
}
}
示例10: registerContainerConfiguration
public function registerContainerConfiguration(LoaderInterface $loader)
{
parent::registerContainerConfiguration($loader);
$loader->load(function (ContainerBuilder $container) {
$container->setParameter('database_user', 'test');
$container->setParameter('database_password', 'test');
$container->setParameter('database_host', 'test');
$container->setParameter('broadway.saga.mongodb.storage_suffix', 'test');
$lockingRepositoryDefinition = new DefinitionDecorator('simgroep_event_sourcing.locking_repository');
$lockingRepositoryDefinition->setClass('Simgroep\\EventSourcing\\Repository\\TestAssets\\Aggregate');
$lockingRepositoryDefinition->addArgument('Simgroep\\EventSourcing\\Repository\\TestAssets\\Aggregate');
$container->setDefinition('locking_repository', $lockingRepositoryDefinition);
});
}
示例11: testNamespaceArgumentIsReplaced
public function testNamespaceArgumentIsReplaced()
{
$container = new ContainerBuilder();
$adapter = new Definition();
$adapter->setAbstract(true);
$adapter->addTag('cache.pool');
$container->setDefinition('app.cache_adapter', $adapter);
$container->setAlias('app.cache_adapter_alias', 'app.cache_adapter');
$cachePool = new DefinitionDecorator('app.cache_adapter_alias');
$cachePool->addArgument(null);
$cachePool->addTag('cache.pool');
$container->setDefinition('app.cache_pool', $cachePool);
$this->cachePoolPass->process($container);
$this->assertSame('kRFqMp5odS', $cachePool->getArgument(0));
}
示例12: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('doctrine')) {
$definition = new DefinitionDecorator('sylius.form.type.object_to_identifier');
$definition->addArgument(new Reference('doctrine'));
$definition->addArgument('sylius_entity_to_identifier');
$definition->addTag('form.type', ['alias' => 'sylius_entity_to_identifier']);
$container->setDefinition('sylius_entity_to_identifier', $definition);
$definition = $container->findDefinition('sylius.form.type.entity_hidden');
$definition->replaceArgument(0, new Reference('doctrine'));
}
if ($container->hasDefinition('doctrine_mongodb')) {
$definition = new DefinitionDecorator('sylius.form.type.object_to_identifier');
$definition->addArgument(new Reference('doctrine_mongodb'));
$definition->addArgument('sylius_document_to_identifier');
$definition->addTag('form.type', ['alias' => 'sylius_document_to_identifier']);
$container->setDefinition('sylius_document_to_identifier', $definition);
if (!$container->hasDefinition('sylius_entity_to_identifier')) {
$container->setAlias('sylius_entity_to_identifier', 'sylius_document_to_identifier');
}
if (!$container->hasDefinition('doctrine')) {
$definition = $container->findDefinition('sylius.form.type.entity_hidden');
$definition->replaceArgument(0, new Reference('doctrine_mongodb'));
}
}
if ($container->hasDefinition('doctrine_phpcr')) {
$definition = new DefinitionDecorator('sylius.form.type.object_to_identifier');
$definition->addArgument(new Reference('doctrine_phpcr'));
$definition->addArgument('sylius_phpcr_document_to_identifier');
$definition->addTag('form.type', ['alias' => 'sylius_phpcr_document_to_identifier']);
$container->setDefinition('sylius_phpcr_document_to_identifier', $definition);
if (!$container->hasDefinition('sylius_entity_to_identifier')) {
$container->setAlias('sylius_entity_to_identifier', 'sylius_phpcr_document_to_identifier');
}
}
}
示例13: createManifestVersionStrategy
protected function createManifestVersionStrategy($packageName, $config)
{
$loader = new DefinitionDecorator($this->namespaceService('manifest.loader.' . $config['format']));
$loader->addArgument($config['path'])->addArgument($config['root_key']);
$loaderId = $this->namespaceService("_package.{$packageName}.manifest_loader");
$this->container->setDefinition($loaderId, $loader);
$cachedLoader = new DefinitionDecorator($this->namespaceService('manifest.loader.cached'));
$cachedLoader->addArgument(new Reference($loaderId));
$cachedLoaderId = $this->namespaceService("_package.{$packageName}.manifest_loader_cached");
$this->container->setDefinition($cachedLoaderId, $cachedLoader);
$versionStrategy = new DefinitionDecorator($this->namespaceService('version_strategy.manifest'));
$versionStrategy->addArgument(new Reference($cachedLoaderId));
$versionStrategyId = $this->namespaceService("_package.{$packageName}.version_strategy");
$this->container->setDefinition($versionStrategyId, $versionStrategy);
return new Reference($versionStrategyId);
}
示例14: process
/**
* @inheritdoc
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('tree_house.queue.event_listener.flush')) {
return;
}
$listener = $container->getDefinition('tree_house.queue.event_listener.flush');
foreach (['doctrine', 'doctrine_mongodb'] as $id) {
if ($container->hasDefinition($id)) {
$flusherId = sprintf('tree_house.queue.flusher.%s', $id);
$definition = new DefinitionDecorator('tree_house.queue.flusher.doctrine_abstract');
$definition->addArgument(new Reference($id));
$container->setDefinition($flusherId, $definition);
$listener->addMethodCall('addFlusher', [new Reference($flusherId)]);
}
}
foreach ($container->findTaggedServiceIds('tree_house.queue.flusher') as $id => list($tag)) {
$listener->addMethodCall('addFlusher', [new Reference($id)]);
}
}
示例15: createAuthorization
private function createAuthorization($config, ContainerBuilder $container)
{
if (!$config['access_control']) {
return;
}
$this->addClassesToCompile(array('Symfony\\Component\\Security\\Http\\AccessMap'));
foreach ($config['access_control'] as $access) {
$matcher = $this->invokeParent('createRequestMatcher', array($container, $access['path'], $access['host'], count($access['methods']) === 0 ? null : $access['methods'], $access['ips']));
if (isset($access['roles'])) {
$attributes = $access['roles'];
} else {
$def = new DefinitionDecorator('security.expressions.expression');
$def->addArgument($access['access']);
$container->setDefinition($exprId = 'security.expressions.expression.' . sha1($access['access']), $def);
$attributes = array(new Reference($exprId));
}
$container->getDefinition('security.access_map')->addMethodCall('add', array($matcher, $attributes, $access['requires_channel']));
}
}