当前位置: 首页>>代码示例>>PHP>>正文


PHP Definition::addArgument方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\Definition::addArgument方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::addArgument方法的具体用法?PHP Definition::addArgument怎么用?PHP Definition::addArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\Definition的用法示例。


在下文中一共展示了Definition::addArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']);
 }
开发者ID:hyrmedia,项目名称:KunstmaanBundlesCMS,代码行数:32,代码来源:KunstmaanVotingExtension.php

示例2: process

 public function process(ContainerBuilder $container)
 {
     $extensions = $container->findTaggedServiceIds('neoclient.extension_class');
     $commandManager = $container->getDefinition('neoclient.command_manager');
     $httpClient = $container->getDefinition('neoclient.http_client');
     $requestBuilder = $container->getDefinition('neoclient.request_builder');
     $extManager = $container->getDefinition('neoclient.extension_manager');
     foreach ($extensions as $id => $params) {
         $definition = $container->getDefinition($id);
         $class = $definition->getClass();
         $commands = $class::getAvailableCommands();
         $extManager->addMethodCall('addExtension', array($class));
         foreach ($commands as $alias => $props) {
             if (array_key_exists($alias, $this->registeredCommands)) {
                 throw new \InvalidArgumentException(sprintf('The command with alias "%s" already exist', $alias));
             }
             $def = new Definition();
             $def->setClass($props['class']);
             $def->addArgument($httpClient);
             $def->addArgument($requestBuilder);
             $container->setDefinition(sprintf('neoclient.command.%s', $alias), $def);
             $commandManager->addMethodCall('registerCommand', array($alias, $def));
             $this->registeredCommands[$alias] = true;
         }
     }
     $customCommands = $container->findTaggedServiceIds('neoclient.custom_command');
     foreach ($customCommands as $id => $params) {
         $def = $container->getDefinition($id);
         $def->addArgument($httpClient);
         $class = $def->getClass();
         $commandManager->addMethodCall('registerCommand', array($params[0][0], $def));
     }
 }
开发者ID:siddhartham-ysg,项目名称:neo4j-neoclient,代码行数:33,代码来源:NeoClientExtensionsCompilerPass.php

示例3: getConnectionReference

 /**
  * @param string                                                  $name
  * @param array                                                   $config
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  *
  * @return \Symfony\Component\DependencyInjection\Reference
  */
 private function getConnectionReference($name, array $config, ContainerBuilder $container)
 {
     if (isset($config['client_id'])) {
         return new Reference($config['client_id']);
     }
     $parameters = array('scheme' => $config['scheme'], 'host' => $config['host'], 'port' => $config['port']);
     if ($config['password']) {
         $parameters['password'] = $config['password'];
     }
     if ($config['timeout']) {
         $parameters['timeout'] = $config['timeout'];
     }
     if ($config['database']) {
         $parameters['database'] = $config['database'];
     }
     $options = null;
     if (isset($config['options'])) {
         $options = $config['options'];
     }
     $clientClass = '%doctrine_cache.predis.client.class%';
     $clientId = sprintf('doctrine_cache.services.%s_predis.client', $name);
     $clientDef = new Definition($clientClass);
     $clientDef->addArgument($parameters);
     $clientDef->addArgument($options);
     $clientDef->setPublic(false);
     $container->setDefinition($clientId, $clientDef);
     return new Reference($clientId);
 }
开发者ID:javiereguiluz,项目名称:DoctrineCacheBundle,代码行数:35,代码来源:PredisDefinition.php

示例4: 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));
         }
     }
 }
开发者ID:fduch,项目名称:workflow-bundle,代码行数:67,代码来源:WorkflowExtension.php

示例5: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $translatableEntityLocaleAssignerDefinition = new Definition(TranslatableEntityLocaleAssigner::class);
     $translatableEntityLocaleAssignerDefinition->addArgument(new Reference('sylius.context.locale'));
     $translatableEntityLocaleAssignerDefinition->addArgument(new Reference('sylius.translation_locale_provider'));
     $container->setDefinition('sylius.translatable_entity_locale_assigner', $translatableEntityLocaleAssignerDefinition);
 }
开发者ID:sylius,项目名称:sylius,代码行数:10,代码来源:TranslatableEntityLocalePass.php

示例6: loadClient

 /**
  * Create client service
  * @param string $name
  * @param array $client
  * @param ContainerBuilder $container
  * @param boolean $testMode
  */
 protected function loadClient($name, array $client, ContainerBuilder $container, $testMode = false)
 {
     $clientDef = new Definition($container->getParameter($testMode ? 'thrift.client.test.class' : 'thrift.client.class'));
     $clientDef->addArgument(new Reference('thrift.factory'));
     $clientDef->addArgument($client);
     $container->setDefinition(sprintf('thrift.client.%s', $name), $clientDef);
 }
开发者ID:pospon,项目名称:ThriftBundle,代码行数:14,代码来源:OverblogThriftExtension.php

示例7: loadRegistrationSubscriber

 private function loadRegistrationSubscriber(ContainerBuilder $container, array $config)
 {
     $definition = new Definition();
     if (array_key_exists('class', $config)) {
         $definition->setClass($config['class']);
     } else {
         $definition->setClass('Tahoe\\Bundle\\MultiTenancyBundle\\EventSubscriber\\RegistrationSubscriber');
     }
     $definition->addTag('kernel.event_subscriber');
     if (array_key_exists('manager', $config)) {
         $definition->addArgument(new Reference($config['manager']));
     } else {
         $definition->addArgument(new Reference('tahoe.multi_tenancy.registration_manager'));
     }
     if (array_key_exists('router', $config)) {
         $definition->addMethodCall('setRouter', array(new Reference($config['router'])));
     } else {
         $definition->addMethodCall('setRouter', array(new Reference('tahoe.multi_tenancy.tenant_aware_router')));
     }
     if (array_key_exists('redirect_route', $config)) {
         $container->setParameter(sprintf("%s.registration_subscriber.redirect_route", $this->getAlias()), $config['redirect_route']);
     } else {
         // default parameter
         $container->setParameter(sprintf("%s.registration_subscriber.redirect_route", $this->getAlias()), 'dashboard');
     }
     // we add the definition to the container
     $container->setDefinition('tahoe.multi_tenancy.registration_subscriber', $definition);
 }
开发者ID:adrianoaguiar,项目名称:multi-tenancy-bundle,代码行数:28,代码来源:TahoeMultiTenancyExtension.php

示例8: parseValidateSchemaConfig

 /**
  * @param array $config
  * @param ContainerBuilder $container
  * @return $this
  */
 protected function parseValidateSchemaConfig(array $config, ContainerBuilder $container)
 {
     if ($config['enabled']) {
         $validateSchemaDefinition = $container->getDefinition('dev.validate_schema');
         foreach ($config['paths'] as $path) {
             $validateSchemaDefinition->addMethodCall('addMappingPath', array($path));
         }
         if ($config['bundles']['enabled']) {
             if (count($config['bundles']['bundles'])) {
                 $bundles = $config['bundles']['bundles'];
             } else {
                 $bundles = array_keys($container->getParameter('kernel.bundles'));
             }
             foreach ($bundles as $bundleName) {
                 $validateSchemaDefinition->addMethodCall('addMappingBundle', array($bundleName));
             }
         }
         $validateSchemaDefinition->addMethodCall('setExcludes', array($config['excludes']));
         $listener = new Definition('steevanb\\DevBundle\\EventListener\\ValidateSchemaListener');
         $listener->addArgument(new Reference('dev.validate_schema'));
         $listener->addArgument($config['disabled_urls']);
         $listener->addTag('kernel.event_listener', array('event' => $config['event'] == 'kernel.request' ? 'kernel.request' : 'kernel.response', 'method' => 'validateSchema'));
         $container->setDefinition('dev.validate_schema.listener', $listener);
     }
     return $this;
 }
开发者ID:steevanb,项目名称:dev-bundle,代码行数:31,代码来源:DevExtension.php

示例9: load

 /**
  * @param ContainerBuilder $container
  * @param array            $config
  */
 public function load(ContainerBuilder $container, array $config)
 {
     $definition = new Definition('Vanare\\BehatCucumberJsonFormatter\\Formatter\\Formatter');
     $definition->addArgument($config['filename']);
     $definition->addArgument($config['outputDir']);
     $container->setDefinition('json.formatter', $definition)->addTag('output.formatter');
 }
开发者ID:vanare,项目名称:behat-cucumber-json-formatter,代码行数:11,代码来源:Extension.php

示例10: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     $config = array();
     foreach ($configs as $subConfig) {
         $config = array_merge($config, $subConfig);
     }
     foreach ($config['email'] as $alias => $options) {
         $optionId = sprintf('rage_notification.email.%s.message', $alias);
         $optionDef = new Definition($container->getParameter('rage_notification.email_message.class'));
         $optionDef->setShared(false);
         $optionDef->addArgument(new Reference('mailer'));
         $optionDef->addArgument(new Reference('templating'));
         if (!empty($options['from'])) {
             $optionDef->addMethodCall('setFrom', [$options['from']]);
         }
         if (!empty($options['reply_to'])) {
             $optionDef->addMethodCall('setReplyTo', [$options['reply_to']]);
         }
         if (!empty($options['embed_images'])) {
             $optionDef->addMethodCall('setEmbedImages', [$options['embed_images']['url'], $options['embed_images']['path']]);
         }
         if (!empty($options['template_path'])) {
             $optionDef->addMethodCall('setTemplatePath', [$options['template_path']]);
         }
         if (!empty($options['css_file'])) {
             $optionDef->addMethodCall('setCssFile', [$options['css_file']]);
         }
         $container->setDefinition($optionId, $optionDef);
         if ($alias === 'default') {
             $container->setAlias('rage_notification.email.message', $optionId);
         }
     }
 }
开发者ID:ragephp,项目名称:notification-bundle,代码行数:35,代码来源:RageNotificationExtension.php

示例11: load

 /**
  * {@inheritdoc}
  */
 public function load(ContainerBuilder $container, array $config)
 {
     $definition = new Definition("FileLineFormatter\\FileLineFormatter");
     $definition->addArgument($config['name']);
     $definition->addArgument('%paths.base%');
     $container->setDefinition("console.formatter", $definition)->addTag("output.formatter");
 }
开发者ID:niklongstone,项目名称:behat-scenario-file-line,代码行数:10,代码来源:FileLineFormatterExtension.php

示例12: create

 public function create(string $class, Reference $factory = null, Reference $repository = null) : Definition
 {
     $definition = new Definition($class);
     $definition->addArgument($factory);
     $definition->addArgument($repository);
     $definition->addMethodCall('setContainer', [new Reference('service_container')]);
     return $definition;
 }
开发者ID:WellCommerce,项目名称:CoreBundle,代码行数:8,代码来源:ManagerDefinitionFactory.php

示例13: configureDefinition

 /**
  * @param                  $contextId
  * @param array            $cellConfig
  * @param ContainerBuilder $container
  * @param Definition       $definition
  *
  * @return Definition
  */
 private function configureDefinition($contextId, array &$cellConfig, ContainerBuilder $container, Definition $definition)
 {
     // Add searcher as first argument
     $definition->addArgument($container->getDefinition($this->buildServiceName($cellConfig[self::SEARCHER_PARAMETER], self::SEARCHER_PARAMETER)));
     // Add transformer as second argument
     $definition->addArgument($this->getTransformerDefinition($container, $contextId, $cellConfig));
     return $definition;
 }
开发者ID:krzysztof-gzocha,项目名称:searcher-bundle,代码行数:16,代码来源:CellCompilerPass.php

示例14: registerResponseListener

 protected function registerResponseListener(ContainerBuilder $container, $cookieExpiryTime)
 {
     $definition = new Definition();
     $definition->setClass($container->getParameter('xsolve.cookie_acknowledgement_bar.event_listener.class'));
     $definition->addArgument(new Reference('xsolve.cookie_acknowledgement_bar.service'));
     $definition->addArgument($cookieExpiryTime);
     $definition->addTag('kernel.event_listener', array('event' => 'kernel.response', 'method' => 'onKernelResponse'));
     $container->setDefinition('xsolve.cookie_acknowledgement_bar.event_listener', $definition);
 }
开发者ID:AdeniaGit,项目名称:adenia.fr,代码行数:9,代码来源:XsolveCookieAcknowledgementExtension.php

示例15: load

 /**
  * Loads extension services into temporary container.
  *
  * @param ContainerBuilder $container
  * @param array $config
  */
 public function load(ContainerBuilder $container, array $config)
 {
     $definition = new Definition("emuse\\BehatHTMLFormatter\\Formatter\\BehatHTMLFormatter");
     $definition->addArgument($config['name']);
     $definition->addArgument($config['renderer']);
     $definition->addArgument($config['file_name']);
     $definition->addArgument('%paths.base%');
     $container->setDefinition("html.formatter", $definition)->addTag("output.formatter");
 }
开发者ID:lifencolor,项目名称:BehatHtmlFormatterPlugin,代码行数:15,代码来源:BehatHTMLFormatterExtension.php


注:本文中的Symfony\Component\DependencyInjection\Definition::addArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。