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


PHP Definition::setMethodCalls方法代码示例

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


在下文中一共展示了Definition::setMethodCalls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: callMethodFirst

 /**
  * @param Definition $definition
  * @param string $methodName
  * @param array $arguments
  */
 private function callMethodFirst(Definition $definition, $methodName, array $arguments)
 {
     $newMethodCall = array($methodName, $arguments);
     $currentMethodCalls = $definition->getMethodCalls();
     array_unshift($currentMethodCalls, $newMethodCall);
     $definition->setMethodCalls($currentMethodCalls);
 }
开发者ID:phatj,项目名称:CrudAbstractDataBundle,代码行数:12,代码来源:CrudTagCompilerPass.php

示例2: mergeMethodCall

 /**
  * @param Definition $definition
  * @param string     $name
  * @param mixed      $value
  */
 public function mergeMethodCall(Definition $definition, $name, $value)
 {
     $methodCalls = $definition->getMethodCalls();
     foreach ($methodCalls as &$calls) {
         foreach ($calls as &$call) {
             if (is_string($call)) {
                 if ($call !== $name) {
                     continue 2;
                 }
                 continue 1;
             }
             $call = array(array_merge($call[0], $value));
         }
     }
     $definition->setMethodCalls($methodCalls);
 }
开发者ID:jayesbe,项目名称:SonataDoctrineORMAdminBundle,代码行数:21,代码来源:AddTemplatesCompilerPass.php

示例3: registerServices

 /**
  * @param array $services
  * @throws \Exception
  */
 protected function registerServices(array $services)
 {
     foreach ($services as $service => $options) {
         if (empty($options['class'])) {
             throw new \Exception(sprintf('Specify your class for %s', $service));
         }
         $arguments = empty($options['arguments']) ? [] : $options['arguments'];
         $definition = new Definition($options['class'], $arguments);
         $definition->setMethodCalls(!strstr($service, 'controller') ? [] : [['setRequest', [new Reference('current_request')]]]);
         if (!empty($options['tags'])) {
             foreach ($options['tags'] as $name => $attributes) {
                 $definition->addTag($name, is_array($attributes) ? $attributes : []);
             }
         }
         $this->builder->setDefinition($service, $definition);
     }
 }
开发者ID:ChiarilloMassimo,项目名称:PixelTracking,代码行数:21,代码来源:ContainerBuilder.php

示例4: injectClassResolverInPlaceHolder

 private function injectClassResolverInPlaceHolder(array $attributes, Definition $serviceInWhichInjectDef, $serviceIdInWhichInjectDef)
 {
     list(, $group) = $this->computeClassResolverId($attributes);
     $classResolverId = $this->getClassResolverIdWithGroup('kassko_class_resolver.chain', $group);
     $index = isset($attributes['index']) ? $attributes['index'] : 0;
     if (!isset($attributes['method'])) {
         $serviceInWhichInjectDef->replaceArgument($index, new Reference($classResolverId));
     } else {
         $method = $attributes['method'];
         $calls = $serviceInWhichInjectDef->getMethodCalls();
         foreach ($calls as &$call) {
             if ($method === $call[0]) {
                 if (!isset($call[1][$index])) {
                     throw new OutOfBoundsException(sprintf('The index attribute "%s" for tag "%s"' . ' and service "%s" is not in the range [0, %d].', $index, $classesToRegisterTag, $serviceIdInWhichInjectDef, count($calls) - 1));
                 }
                 $call[1][$index] = new Reference($classResolverId);
             }
         }
         unset($call);
         //Precaution.
         $serviceInWhichInjectDef->setMethodCalls($calls);
     }
 }
开发者ID:kassko,项目名称:with-symfony,代码行数:23,代码来源:InjectClassResolversPass.php

示例5: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $config = $this->processConfiguration(new Configuration(), $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $container->setAlias('avoo_achievement', $config['service']['class']);
     $container->setParameter('avoo_achievement.repository', $config['user_achievement_class']);
     $categories = array();
     if (!empty($config['achievements'])) {
         $categories = array_keys($config['achievements']);
     }
     $container->setParameter('avoo_achievement.categories', $categories);
     foreach ($config['achievements'] as $category => $achievements) {
         foreach ($achievements as $type => $achievement) {
             $definition = new Definition();
             $definition->setClass($achievement['class']);
             $definition->setArguments(array('manager' => new Reference('doctrine.orm.default_entity_manager')));
             $options = new Definition('Avoo\\AchievementBundle\\Listener\\AchievementOptions', array(array('id' => $category . '.' . $type, 'category' => $category, 'name' => $achievement['name'], 'value' => $achievement['value'], 'description' => isset($achievement['description']) ? $achievement['description'] : null, 'image' => $achievement['image'])));
             $definition->setMethodCalls(array(array('setOptions', array($options)), array('setUser', array(new Reference('security.token_storage'))), array('setRepository', array($config['user_achievement_class']))));
             $definition->addTag('avoo_achievement.achievement', array('type' => $category . '.' . $type));
             $container->setDefinition(sprintf('avoo_achievement.achievement.%s.%s', $category, $type), $definition);
         }
     }
 }
开发者ID:avoo,项目名称:AchievementBundle,代码行数:27,代码来源:AvooAchievementExtension.php

示例6: resolveDefinition

 /**
  * Resolves the definition.
  *
  * @param ContainerBuilder    $container  The ContainerBuilder
  * @param DefinitionDecorator $definition
  *
  * @return Definition
  *
  * @throws \RuntimeException When the definition is invalid
  */
 private function resolveDefinition(ContainerBuilder $container, DefinitionDecorator $definition)
 {
     if (!$container->hasDefinition($parent = $definition->getParent())) {
         throw new RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $this->currentId));
     }
     $parentDef = $container->getDefinition($parent);
     if ($parentDef instanceof DefinitionDecorator) {
         $id = $this->currentId;
         $this->currentId = $parent;
         $parentDef = $this->resolveDefinition($container, $parentDef);
         $container->setDefinition($parent, $parentDef);
         $this->currentId = $id;
     }
     $this->compiler->addLogMessage($this->formatter->formatResolveInheritance($this, $this->currentId, $parent));
     $def = new Definition();
     // merge in parent definition
     // purposely ignored attributes: scope, abstract, tags
     $def->setClass($parentDef->getClass());
     $def->setArguments($parentDef->getArguments());
     $def->setMethodCalls($parentDef->getMethodCalls());
     $def->setProperties($parentDef->getProperties());
     $def->setAutowiringTypes($parentDef->getAutowiringTypes());
     if ($parentDef->getFactoryClass(false)) {
         $def->setFactoryClass($parentDef->getFactoryClass(false));
     }
     if ($parentDef->getFactoryMethod(false)) {
         $def->setFactoryMethod($parentDef->getFactoryMethod(false));
     }
     if ($parentDef->getFactoryService(false)) {
         $def->setFactoryService($parentDef->getFactoryService(false));
     }
     if ($parentDef->isDeprecated()) {
         $def->setDeprecated(true, $parentDef->getDeprecationMessage('%service_id%'));
     }
     $def->setFactory($parentDef->getFactory());
     $def->setConfigurator($parentDef->getConfigurator());
     $def->setFile($parentDef->getFile());
     $def->setPublic($parentDef->isPublic());
     $def->setLazy($parentDef->isLazy());
     // overwrite with values specified in the decorator
     $changes = $definition->getChanges();
     if (isset($changes['class'])) {
         $def->setClass($definition->getClass());
     }
     if (isset($changes['factory_class'])) {
         $def->setFactoryClass($definition->getFactoryClass(false));
     }
     if (isset($changes['factory_method'])) {
         $def->setFactoryMethod($definition->getFactoryMethod(false));
     }
     if (isset($changes['factory_service'])) {
         $def->setFactoryService($definition->getFactoryService(false));
     }
     if (isset($changes['factory'])) {
         $def->setFactory($definition->getFactory());
     }
     if (isset($changes['configurator'])) {
         $def->setConfigurator($definition->getConfigurator());
     }
     if (isset($changes['file'])) {
         $def->setFile($definition->getFile());
     }
     if (isset($changes['public'])) {
         $def->setPublic($definition->isPublic());
     }
     if (isset($changes['lazy'])) {
         $def->setLazy($definition->isLazy());
     }
     if (isset($changes['deprecated'])) {
         $def->setDeprecated($definition->isDeprecated(), $definition->getDeprecationMessage('%service_id%'));
     }
     if (isset($changes['decorated_service'])) {
         $decoratedService = $definition->getDecoratedService();
         if (null === $decoratedService) {
             $def->setDecoratedService($decoratedService);
         } else {
             $def->setDecoratedService($decoratedService[0], $decoratedService[1], $decoratedService[2]);
         }
     }
     // merge arguments
     foreach ($definition->getArguments() as $k => $v) {
         if (is_numeric($k)) {
             $def->addArgument($v);
             continue;
         }
         if (0 !== strpos($k, 'index_')) {
             throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k));
         }
         $index = (int) substr($k, strlen('index_'));
         $def->replaceArgument($index, $v);
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:ResolveDefinitionTemplatesPass.php

示例7: fixTemplates

 /**
  * @param  \Symfony\Component\DependencyInjection\ContainerBuilder $container
  * @param  \Symfony\Component\DependencyInjection\Definition       $definition
  *
  * @return void
  */
 public function fixTemplates(ContainerBuilder $container, Definition $definition)
 {
     $definedTemplates = $container->getParameter('sonata.admin.configuration.templates');
     $methods = array();
     $pos = 0;
     foreach ($definition->getMethodCalls() as $method) {
         if ($method[0] == 'setTemplates') {
             $definedTemplates = array_merge($definedTemplates, $method[1][0]);
             continue;
         }
         if ($method[0] == 'setTemplate') {
             $definedTemplates[$method[1][0]] = $method[1][1];
             continue;
         }
         $methods[$pos] = $method;
         $pos++;
     }
     $definition->setMethodCalls($methods);
     // make sure the default templates are defined
     $definedTemplates = array_merge(array('user_block' => 'SonataAdminBundle:Core:user_block.html.twig', 'add_block' => 'SonataAdminBundle:Core:add_block.html.twig', 'layout' => 'SonataAdminBundle::standard_layout.html.twig', 'ajax' => 'SonataAdminBundle::ajax_layout.html.twig', 'dashboard' => 'SonataAdminBundle:Core:dashboard.html.twig', 'list' => 'SonataAdminBundle:CRUD:list.html.twig', 'filter' => 'SonataAdminBundle:Form:filter_admin_fields.html.twig', 'show' => 'SonataAdminBundle:CRUD:show.html.twig', 'show_compare' => 'SonataAdminBundle:CRUD:show_compare.html.twig', 'edit' => 'SonataAdminBundle:CRUD:edit.html.twig', 'history' => 'SonataAdminBundle:CRUD:history.html.twig', 'history_revision_timestamp' => 'SonataAdminBundle:CRUD:history_revision_timestamp.html.twig', 'acl' => 'SonataAdminBundle:CRUD:acl.html.twig', 'action' => 'SonataAdminBundle:CRUD:action.html.twig', 'short_object_description' => 'SonataAdminBundle:Helper:short-object-description.html.twig', 'preview' => 'SonataAdminBundle:CRUD:preview.html.twig', 'list_block' => 'SonataAdminBundle:Block:block_admin_list.html.twig', 'delete' => 'SonataAdminBundle:CRUD:delete.html.twig', 'batch' => 'SonataAdminBundle:CRUD:list__batch.html.twig', 'select' => 'SonataAdminBundle:CRUD:list__select.html.twig', 'batch_confirmation' => 'SonataAdminBundle:CRUD:batch_confirmation.html.twig', 'inner_list_row' => 'SonataAdminBundle:CRUD:list_inner_row.html.twig', 'base_list_field' => 'SonataAdminBundle:CRUD:base_list_field.html.twig', 'pager_links' => 'SonataAdminBundle:Pager:links.html.twig', 'pager_results' => 'SonataAdminBundle:Pager:results.html.twig', 'tab_menu_template' => 'SonataAdminBundle:Core:tab_menu_template.html.twig'), $definedTemplates);
     $definition->addMethodCall('setTemplates', array($definedTemplates));
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:28,代码来源:AddDependencyCallsCompilerPass.php

示例8: resolveDefinition

 /**
  * Resolves the definition
  *
  * @param string              $id         The definition identifier
  * @param DefinitionDecorator $definition
  *
  * @return Definition
  */
 private function resolveDefinition($id, DefinitionDecorator $definition)
 {
     if (!$this->container->hasDefinition($parent = $definition->getParent())) {
         throw new RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $id));
     }
     $parentDef = $this->container->getDefinition($parent);
     if ($parentDef instanceof DefinitionDecorator) {
         $parentDef = $this->resolveDefinition($parent, $parentDef);
     }
     $this->compiler->addLogMessage($this->formatter->formatResolveInheritance($this, $id, $parent));
     $def = new Definition();
     // merge in parent definition
     // purposely ignored attributes: scope, abstract, tags
     $def->setClass($parentDef->getClass());
     $def->setArguments($parentDef->getArguments());
     $def->setMethodCalls($parentDef->getMethodCalls());
     $def->setProperties($parentDef->getProperties());
     $def->setFactoryClass($parentDef->getFactoryClass());
     $def->setFactoryMethod($parentDef->getFactoryMethod());
     $def->setFactoryService($parentDef->getFactoryService());
     $def->setConfigurator($parentDef->getConfigurator());
     $def->setFile($parentDef->getFile());
     $def->setPublic($parentDef->isPublic());
     // overwrite with values specified in the decorator
     $changes = $definition->getChanges();
     if (isset($changes['class'])) {
         $def->setClass($definition->getClass());
     }
     if (isset($changes['factory_class'])) {
         $def->setFactoryClass($definition->getFactoryClass());
     }
     if (isset($changes['factory_method'])) {
         $def->setFactoryMethod($definition->getFactoryMethod());
     }
     if (isset($changes['factory_service'])) {
         $def->setFactoryService($definition->getFactoryService());
     }
     if (isset($changes['configurator'])) {
         $def->setConfigurator($definition->getConfigurator());
     }
     if (isset($changes['file'])) {
         $def->setFile($definition->getFile());
     }
     if (isset($changes['public'])) {
         $def->setPublic($definition->isPublic());
     }
     // merge arguments
     foreach ($definition->getArguments() as $k => $v) {
         if (is_numeric($k)) {
             $def->addArgument($v);
             continue;
         }
         if (0 !== strpos($k, 'index_')) {
             throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k));
         }
         $index = (int) substr($k, strlen('index_'));
         $def->replaceArgument($index, $v);
     }
     // merge properties
     foreach ($definition->getProperties() as $k => $v) {
         $def->setProperty($k, $v);
     }
     // append method calls
     if (count($calls = $definition->getMethodCalls()) > 0) {
         $def->setMethodCalls(array_merge($def->getMethodCalls(), $calls));
     }
     // these attributes are always taken from the child
     $def->setAbstract($definition->isAbstract());
     $def->setScope($definition->getScope());
     $def->setTags($definition->getTags());
     // set new definition on container
     $this->container->setDefinition($id, $def);
     return $def;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:82,代码来源:ResolveDefinitionTemplatesPass.php

示例9: fixTemplates

 /**
  * @param ContainerBuilder $container
  * @param Definition       $definition
  * @param array            $overwrittenTemplates
  */
 public function fixTemplates(ContainerBuilder $container, Definition $definition, array $overwrittenTemplates = array())
 {
     $definedTemplates = $container->getParameter('sonata.admin.configuration.templates');
     $methods = array();
     $pos = 0;
     foreach ($definition->getMethodCalls() as $method) {
         if ($method[0] == 'setTemplates') {
             $definedTemplates = array_merge($definedTemplates, $method[1][0]);
             continue;
         }
         if ($method[0] == 'setTemplate') {
             $definedTemplates[$method[1][0]] = $method[1][1];
             continue;
         }
         // set template for simple pager if it is not already overwritten
         if ($method[0] === 'setPagerType' && $method[1][0] === Pager::TYPE_SIMPLE && (!isset($definedTemplates['pager_results']) || $definedTemplates['pager_results'] === 'SonataAdminBundle:Pager:results.html.twig')) {
             $definedTemplates['pager_results'] = 'SonataAdminBundle:Pager:simple_pager_results.html.twig';
         }
         $methods[$pos] = $method;
         ++$pos;
     }
     $definition->setMethodCalls($methods);
     // make sure the default templates are defined
     $definedTemplates = array_merge(array('user_block' => 'SonataAdminBundle:Core:user_block.html.twig', 'add_block' => 'SonataAdminBundle:Core:add_block.html.twig', 'layout' => 'SonataAdminBundle::standard_layout.html.twig', 'ajax' => 'SonataAdminBundle::ajax_layout.html.twig', 'dashboard' => 'SonataAdminBundle:Core:dashboard.html.twig', 'list' => 'SonataAdminBundle:CRUD:list.html.twig', 'filter' => 'SonataAdminBundle:Form:filter_admin_fields.html.twig', 'show' => 'SonataAdminBundle:CRUD:show.html.twig', 'show_compare' => 'SonataAdminBundle:CRUD:show_compare.html.twig', 'edit' => 'SonataAdminBundle:CRUD:edit.html.twig', 'history' => 'SonataAdminBundle:CRUD:history.html.twig', 'history_revision_timestamp' => 'SonataAdminBundle:CRUD:history_revision_timestamp.html.twig', 'acl' => 'SonataAdminBundle:CRUD:acl.html.twig', 'action' => 'SonataAdminBundle:CRUD:action.html.twig', 'short_object_description' => 'SonataAdminBundle:Helper:short-object-description.html.twig', 'preview' => 'SonataAdminBundle:CRUD:preview.html.twig', 'list_block' => 'SonataAdminBundle:Block:block_admin_list.html.twig', 'delete' => 'SonataAdminBundle:CRUD:delete.html.twig', 'batch' => 'SonataAdminBundle:CRUD:list__batch.html.twig', 'select' => 'SonataAdminBundle:CRUD:list__select.html.twig', 'batch_confirmation' => 'SonataAdminBundle:CRUD:batch_confirmation.html.twig', 'inner_list_row' => 'SonataAdminBundle:CRUD:list_inner_row.html.twig', 'base_list_field' => 'SonataAdminBundle:CRUD:base_list_field.html.twig', 'pager_links' => 'SonataAdminBundle:Pager:links.html.twig', 'pager_results' => 'SonataAdminBundle:Pager:results.html.twig', 'tab_menu_template' => 'SonataAdminBundle:Core:tab_menu_template.html.twig', 'knp_menu_template' => 'SonataAdminBundle:Menu:sonata_menu.html.twig', 'outer_list_rows_mosaic' => 'SonataAdminBundle:CRUD:list_outer_rows_mosaic.html.twig', 'outer_list_rows_list' => 'SonataAdminBundle:CRUD:list_outer_rows_list.html.twig', 'outer_list_rows_tree' => 'SonataAdminBundle:CRUD:list_outer_rows_tree.html.twig'), $definedTemplates, $overwrittenTemplates['view']);
     $definition->addMethodCall('setTemplates', array($definedTemplates));
 }
开发者ID:ejkun,项目名称:SonataAdminBundle,代码行数:31,代码来源:AddDependencyCallsCompilerPass.php

示例10: registerController

 private function registerController(ContainerBuilder $container, $id, $class, $calls = array())
 {
     $controller = new Definition($class);
     $controller->setMethodCalls($calls);
     $container->setDefinition($id, $controller);
 }
开发者ID:sfraoua,项目名称:CartBundle,代码行数:6,代码来源:LeaphlyCartExtension.php

示例11: testProcess

 public function testProcess()
 {
     $container = new ContainerBuilder();
     $container->setParameter('ezpublish.config_resolver.updateable_services', array());
     $updateableServices = array();
     $def1Arg1 = 'foo';
     $def1Arg2 = new Reference('foo.bar');
     $def1 = new Definition('stdClass', array($def1Arg1, $def1Arg2));
     $def2 = new Definition('stdClass', array('$bar;some_namespace$', array()));
     $def3 = new Definition('stdClass', array('$content.default_ttl;ezsettings;ezdemo_site_admin$'));
     $def4 = new Definition('stdClass', array('$languages$'));
     $def5Arg1 = new Reference('def3');
     $def5 = new Definition('stdClass', array($def5Arg1));
     $def6Arg1 = new Reference('def1');
     $def6Arg2 = new Reference('def4');
     $def6 = new Definition('stdClass', array($def6Arg1, $def6Arg2));
     $def7MethodCalls = array(array('setFoo', array('something', new Reference('def1'))), array('setBar', array(array('baz'))));
     $def7 = new Definition('stdClass');
     $def7->setMethodCalls($def7MethodCalls);
     $def8MethodCalls = array(array('setFoo', array('$foo$')), array('setBar', array('$bar;baz$')));
     $def8 = new Definition('stdClass');
     $def8->setMethodCalls($def8MethodCalls);
     $container->setDefinitions(array('def1' => $def1, 'def2' => $def2, 'def3' => $def3, 'def4' => $def4, 'def5' => $def5, 'def6' => $def6, 'def7' => $def7, 'def8' => $def8));
     $configResolverPass = new ConfigResolverParameterPass(new DynamicSettingParser());
     $configResolverPass->process($container);
     // Ensure that non concerned services stayed untouched.
     self::assertSame($def1Arg1, $def1->getArgument(0));
     self::assertSame($def1Arg2, $def1->getArgument(1));
     self::assertSame($def1, $container->getDefinition('def1'));
     self::assertSame($def5Arg1, $def5->getArgument(0));
     self::assertSame($def5, $container->getDefinition('def5'));
     self::assertSame($def6Arg1, $def6->getArgument(0));
     self::assertSame($def6Arg2, $def6->getArgument(1));
     self::assertSame($def6, $container->getDefinition('def6'));
     self::assertSame($def7MethodCalls, $def7->getMethodCalls());
     self::assertSame($def7, $container->getDefinition('def7'));
     // Check that concerned services arguments have been correctly transformed.
     $def2arg1 = $def2->getArgument(0);
     self::assertInstanceOf('Symfony\\Component\\ExpressionLanguage\\Expression', $def2arg1);
     self::assertSame('service("ezpublish.config.resolver").getParameter("bar", "some_namespace", null)', (string) $def2arg1);
     // Also check 2nd argument
     self::assertSame(array(), $def2->getArgument(1));
     $def3arg1 = $def3->getArgument(0);
     self::assertInstanceOf('Symfony\\Component\\ExpressionLanguage\\Expression', $def3arg1);
     self::assertSame('service("ezpublish.config.resolver").getParameter("content.default_ttl", "ezsettings", "ezdemo_site_admin")', (string) $def3arg1);
     $def4arg1 = $def4->getArgument(0);
     self::assertInstanceOf('Symfony\\Component\\ExpressionLanguage\\Expression', $def4arg1);
     self::assertSame('service("ezpublish.config.resolver").getParameter("languages", null, null)', (string) $def4arg1);
     $def8Calls = $def8->getMethodCalls();
     self::assertSame(count($def8MethodCalls), count($def8Calls));
     self::assertSame($def8MethodCalls[0][0], $def8Calls[0][0]);
     self::assertInstanceOf('Symfony\\Component\\ExpressionLanguage\\Expression', $def8Calls[0][1][0]);
     $exprSetFoo = 'service("ezpublish.config.resolver").getParameter("foo", null, null)';
     self::assertSame($exprSetFoo, (string) $def8Calls[0][1][0]);
     self::assertSame($def8MethodCalls[1][0], $def8Calls[1][0]);
     self::assertInstanceOf('Symfony\\Component\\ExpressionLanguage\\Expression', $def8Calls[1][1][0]);
     $exprSetBar = 'service("ezpublish.config.resolver").getParameter("bar", "baz", null)';
     self::assertSame($exprSetBar, (string) $def8Calls[1][1][0]);
     $updateableServices['def8'] = array(array('setFoo', $exprSetFoo), array('setBar', $exprSetBar));
     self::assertTrue($container->hasParameter('ezpublish.config_resolver.resettable_services'));
     self::assertEquals(array('def2', 'def3', 'def4', 'def5', 'def6'), $container->getParameter('ezpublish.config_resolver.resettable_services'));
     self::assertEquals($updateableServices, $container->getParameter('ezpublish.config_resolver.updateable_services'));
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:63,代码来源:ConfigResolverParameterPassTest.php

示例12: testProcess

 public function testProcess()
 {
     $container = new ContainerBuilder();
     $dynamicSettingsServices = array();
     $def1Arg1 = 'foo';
     $def1Arg2 = new Reference('foo.bar');
     $def1 = new Definition('stdClass', array($def1Arg1, $def1Arg2));
     $def2 = new Definition('stdClass', array('$bar;some_namespace$', array()));
     $def3 = new Definition('stdClass', array('$content.default_ttl;ezsettings;ezdemo_site_admin$'));
     $def4 = new Definition('stdClass', array('$languages$'));
     $def5Arg1 = new Reference('def3');
     $def5 = new Definition('stdClass', array($def5Arg1));
     $def6Arg1 = new Reference('def1');
     $def6Arg2 = new Reference('def4');
     $def6 = new Definition('stdClass', array($def6Arg1, $def6Arg2));
     $def7MethodCalls = array(array('setFoo', array('something', new Reference('def1'))), array('setBar', array(array('baz'))));
     $def7 = new Definition('stdClass');
     $def7->setMethodCalls($def7MethodCalls);
     $def8MethodCalls = array(array('setFoo', array('$foo$')), array('setBar', array('$bar;baz$')));
     $def8 = new Definition('stdClass');
     $def8->setMethodCalls($def8MethodCalls);
     $container->setDefinitions(array('def1' => $def1, 'def2' => $def2, 'def3' => $def3, 'def4' => $def4, 'def5' => $def5, 'def6' => $def6, 'def7' => $def7, 'def8' => $def8));
     $configResolverPass = new ConfigResolverParameterPass(new DynamicSettingParser());
     $configResolverPass->process($container);
     // Ensure that non concerned services stayed untouched.
     $this->assertSame($def1Arg1, $def1->getArgument(0));
     $this->assertSame($def1Arg2, $def1->getArgument(1));
     $this->assertSame($def1, $container->getDefinition('def1'));
     $this->assertSame($def5Arg1, $def5->getArgument(0));
     $this->assertSame($def5, $container->getDefinition('def5'));
     $this->assertSame($def6Arg1, $def6->getArgument(0));
     $this->assertSame($def6Arg2, $def6->getArgument(1));
     $this->assertSame($def6, $container->getDefinition('def6'));
     $this->assertSame($def7MethodCalls, $def7->getMethodCalls());
     $this->assertSame($def7, $container->getDefinition('def7'));
     // Check that concerned services arguments have been correctly transformed.
     /** @var Reference $def2arg1 */
     $def2arg1 = $def2->getArgument(0);
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $def2arg1);
     $expectedServiceHelperId1 = 'ezpublish.config_resolver.fake.bar_some_namespace_';
     $dynamicSettingsServices[] = $expectedServiceHelperId1;
     $this->assertSame((string) $def2arg1, $expectedServiceHelperId1);
     $this->assertTrue($container->has($expectedServiceHelperId1));
     $defHelper1 = $container->getDefinition($expectedServiceHelperId1);
     $this->assertSame('ezpublish.config.resolver', $defHelper1->getFactoryService());
     $this->assertSame('getParameter', $defHelper1->getFactoryMethod());
     $this->assertSame(array('bar', 'some_namespace', null), $defHelper1->getArguments());
     // Also check 2nd argument
     $this->assertSame(array(), $def2->getArgument(1));
     /** @var Reference $def3arg1 */
     $def3arg1 = $def3->getArgument(0);
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $def3arg1);
     $expectedServiceHelperId2 = 'ezpublish.config_resolver.fake.content.default_ttl_ezsettings_ezdemo_site_admin';
     $dynamicSettingsServices[] = $expectedServiceHelperId2;
     $this->assertSame((string) $def3arg1, $expectedServiceHelperId2);
     $this->assertTrue($container->has($expectedServiceHelperId2));
     $defHelper2 = $container->getDefinition($expectedServiceHelperId2);
     $this->assertSame('ezpublish.config.resolver', $defHelper2->getFactoryService());
     $this->assertSame('getParameter', $defHelper2->getFactoryMethod());
     $this->assertSame(array('content.default_ttl', 'ezsettings', 'ezdemo_site_admin'), $defHelper2->getArguments());
     /** @var Reference $def4arg1 */
     $def4arg1 = $def4->getArgument(0);
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $def4arg1);
     $expectedServiceHelperId3 = 'ezpublish.config_resolver.fake.languages__';
     $dynamicSettingsServices[] = $expectedServiceHelperId3;
     $this->assertSame((string) $def4arg1, $expectedServiceHelperId3);
     $this->assertTrue($container->has($expectedServiceHelperId3));
     $defHelper3 = $container->getDefinition($expectedServiceHelperId3);
     $this->assertSame('ezpublish.config.resolver', $defHelper3->getFactoryService());
     $this->assertSame('getParameter', $defHelper3->getFactoryMethod());
     $this->assertSame(array('languages', null, null), $defHelper3->getArguments());
     /** @var Reference $def4arg1 */
     $def8Calls = $def8->getMethodCalls();
     $this->assertSame(count($def8MethodCalls), count($def8Calls));
     $this->assertSame($def8MethodCalls[0][0], $def8Calls[0][0]);
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $def8Calls[0][1][0]);
     $expectedServiceHelperId4 = 'ezpublish.config_resolver.fake.foo__';
     $dynamicSettingsServices[] = $expectedServiceHelperId4;
     $this->assertSame((string) $def8Calls[0][1][0], $expectedServiceHelperId4);
     $this->assertTrue($container->has($expectedServiceHelperId4));
     $defHelper4 = $container->getDefinition($expectedServiceHelperId4);
     $this->assertSame('ezpublish.config.resolver', $defHelper4->getFactoryService());
     $this->assertSame('getParameter', $defHelper4->getFactoryMethod());
     $this->assertSame(array('foo', null, null), $defHelper4->getArguments());
     $this->assertSame($def8MethodCalls[1][0], $def8Calls[1][0]);
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $def8Calls[1][1][0]);
     $expectedServiceHelperId5 = 'ezpublish.config_resolver.fake.bar_baz_';
     $dynamicSettingsServices[] = $expectedServiceHelperId5;
     $this->assertSame((string) $def8Calls[1][1][0], $expectedServiceHelperId5);
     $this->assertTrue($container->has($expectedServiceHelperId5));
     $defHelper5 = $container->getDefinition($expectedServiceHelperId5);
     $this->assertSame('ezpublish.config.resolver', $defHelper5->getFactoryService());
     $this->assertSame('getParameter', $defHelper5->getFactoryMethod());
     $this->assertSame(array('bar', 'baz', null), $defHelper5->getArguments());
     $this->assertTrue($container->hasParameter('ezpublish.config_resolver.resettable_services'));
     $this->assertEquals(array('def2', 'def3', 'def4', 'def5', 'def6'), $container->getParameter('ezpublish.config_resolver.resettable_services'));
     $this->assertTrue($container->hasParameter('ezpublish.config_resolver.dynamic_settings_services'));
     $this->assertEquals($dynamicSettingsServices, $container->getParameter('ezpublish.config_resolver.dynamic_settings_services'));
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:99,代码来源:ConfigResolverParameterPassTest.php

示例13: setMethodCalls

 /**
  * Set the methods to call after service initialization.
  *
  * @param array $calls An array of method calls
  *
  * @return tubepress_api_ioc_DefinitionInterface The current instance
  *
  * @api
  * @since 4.0.0
  */
 public function setMethodCalls(array $calls = array())
 {
     $cleaned = $this->convertToSymfonyReferenceIfNecessary($calls);
     $this->_underlyingSymfonyDefinition->setMethodCalls($cleaned);
     return $this;
 }
开发者ID:tubepress,项目名称:tubepress,代码行数:16,代码来源:Definition.php

示例14: fixTemplates

 /**
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  * @param \Symfony\Component\DependencyInjection\Definition $definition
  * @return void
  */
 public function fixTemplates(ContainerBuilder $container, Definition $definition)
 {
     $definedTemplates = $container->getParameter('sonata.admin.configuration.templates');
     $methods = array();
     $pos = 0;
     foreach ($definition->getMethodCalls() as $method) {
         if ($method[0] == 'setTemplates') {
             $definedTemplates = array_merge($definedTemplates, $method[1][0]);
             continue;
         }
         if ($method[0] == 'setTemplate') {
             $definedTemplates[$method[1][0]] = $method[1][1];
             continue;
         }
         $methods[$pos] = $method;
         $pos++;
     }
     $definition->setMethodCalls($methods);
     // make sure the default templates are defined
     $definedTemplates = array_merge(array('user_block' => 'SonataAdminBundle:Core:user_block.html.twig', 'layout' => 'SonataAdminBundle::standard_layout.html.twig', 'ajax' => 'SonataAdminBundle::ajax_layout.html.twig', 'dashboard' => 'SonataAdminBundle:Core:dashboard.html.twig', 'list' => 'SonataAdminBundle:CRUD:list.html.twig', 'show' => 'SonataAdminBundle:CRUD:show.html.twig', 'edit' => 'SonataAdminBundle:CRUD:edit.html.twig', 'history' => 'SonataAdminBundle:CRUD:history.html.twig', 'history_revision' => 'SonataAdminBundle:CRUD:history_revision.html.twig', 'action' => 'SonataAdminBundle:CRUD:action.html.twig', 'short_object_description' => 'SonataAdminBundle:Helper:short-object-description.html.twig'), $definedTemplates);
     $definition->addMethodCall('setTemplates', array($definedTemplates));
 }
开发者ID:rigosv,项目名称:SonataAdminBundle,代码行数:27,代码来源:AddDependencyCallsCompilerPass.php

示例15: autowireSetters

 /**
  * @param string $class
  * @param Definition $definition
  * @param string[] $classes
  * @param string $id
  * @param ContainerBuilder $container
  */
 private function autowireSetters($class, Definition $definition, array $classes, $id, ContainerBuilder $container)
 {
     $newCalls = array();
     foreach ($definition->getMethodCalls() as $call) {
         $method = new ReflectionMethod($class, $call[0]);
         $autowiredArgs = $this->autowireMethod($method, $call[1], $classes, $id, $container);
         $newCalls[] = array($call[0], $autowiredArgs);
     }
     $definition->setMethodCalls($newCalls);
 }
开发者ID:janmarek,项目名称:autowiring-bundle,代码行数:17,代码来源:AutowiringPass.php


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