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


PHP ContainerBuilder::getServiceIds方法代码示例

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


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

示例1: testConfig

 public function testConfig()
 {
     $this->createFullConfiguration();
     $this->assertParameter('foo_key', 'freshdesk_api_key');
     $this->assertParameter('bar_domain', 'freshdesk_domain');
     $this->assertContains('freshdesk', $this->containerBuilder->getServiceIds());
 }
开发者ID:mpclarkson,项目名称:freshdesk-bundle,代码行数:7,代码来源:FreshdeskExtensionTest.php

示例2: collect

 /**
  * Collect information about services and parameters from the cached dumped xml container
  *
  * @param Request    $request   The Request Object
  * @param Response   $response  The Response Object
  * @param \Exception $exception The Exception
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $parameters = array();
     $services = array();
     $this->loadContainerBuilder();
     if ($this->containerBuilder !== false) {
         foreach ($this->containerBuilder->getParameterBag()->all() as $key => $value) {
             $service = substr($key, 0, strpos($key, '.'));
             if (!isset($parameters[$service])) {
                 $parameters[$service] = array();
             }
             $parameters[$service][$key] = $value;
         }
         $serviceIds = $this->containerBuilder->getServiceIds();
         foreach ($serviceIds as $serviceId) {
             $definition = $this->resolveServiceDefinition($serviceId);
             if ($definition instanceof Definition && $definition->isPublic()) {
                 $services[$serviceId] = array('class' => $definition->getClass(), 'scope' => $definition->getScope());
             } elseif ($definition instanceof Alias) {
                 $services[$serviceId] = array('alias' => $definition);
             } else {
                 continue;
                 // We don't want private services
             }
         }
         ksort($services);
         ksort($parameters);
     }
     $this->data['parameters'] = $parameters;
     $this->data['services'] = $services;
 }
开发者ID:LittleTwoCheng,项目名称:WebProfilerExtraBundle,代码行数:38,代码来源:ContainerDataCollector.php

示例3: testLoad

 /**
  * Test related method
  */
 public function testLoad()
 {
     $this->extension->load($this->configs, $this->containerBuilder);
     $serviceIds = $this->containerBuilder->getServiceIds();
     $this->assertCount(3, $serviceIds);
     $this->assertTrue(in_array(self::PIM_TRANSLATION_FORM_TYPE, $serviceIds));
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:10,代码来源:PimTranslationExtensionTest.php

示例4: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     $this->containerBuilder = $this->getContainerBuilder();
     $tag = $input->getOption('tag');
     if ($input->getOption('tags')) {
         if ($tag || $input->getArgument('name')) {
             throw new \InvalidArgumentException('The --tags option cannot be combined with the --tag option or the service name argument.');
         }
         $this->outputTags($output, $input->getOption('show-private'));
         return;
     }
     if (null !== $tag) {
         if ($input->getArgument('name')) {
             throw new \InvalidArgumentException('The --tag option cannot be combined with the service name argument.');
         }
         $serviceIds = array_keys($this->containerBuilder->findTaggedServiceIds($tag));
     } else {
         $serviceIds = $this->containerBuilder->getServiceIds();
     }
     // sort so that it reads like an index of services
     asort($serviceIds);
     if ($name) {
         $this->outputService($output, $name);
     } else {
         $this->outputServices($output, $serviceIds, $input->getOption('show-private'), $tag);
     }
 }
开发者ID:nicam,项目名称:symfony,代码行数:31,代码来源:ContainerDebugCommand.php

示例5: testContainerHasNeccessaryServices

 public function testContainerHasNeccessaryServices()
 {
     $this->loadConfiguration();
     $entityClass = $this->containerBuilder->getParameter('melifaro_booking.entity_class');
     $services = $this->containerBuilder->getServiceIds();
     $this->assertEquals('Vendor\\Bundle\\Entity\\Class', $entityClass);
     $this->assertContains('booker', $services);
     $this->assertContains('booking_calendar', $services);
 }
开发者ID:vfroid,项目名称:MelifaroBookingBundle,代码行数:9,代码来源:MelifaroBookingExtensionTest.php

示例6: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->initContainerBuilder();
     $ids = $this->containerBuilder->getServiceIds();
     foreach ($ids as $serviceId) {
         try {
             $this->handleService($input, $output, $serviceId);
         } catch (InvalidArgumentException $e) {
             $output->writeln(sprintf('<error>%s: %s</error>', $serviceId, $e->getMessage()));
         }
     }
 }
开发者ID:brainexe,项目名称:core,代码行数:15,代码来源:TestCreateAllCommand.php

示例7: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filter = $input->getArgument('name');
     $this->containerBuilder = $this->getContainerBuilder();
     $serviceIds = $this->filterServices($this->containerBuilder->getServiceIds(), $filter);
     if (1 == count($serviceIds) && false === strpos($filter, '*')) {
         $this->outputService($output, $serviceIds[0]);
     } else {
         $showPrivate = $input->getOption('show-private');
         $this->outputServices($output, $serviceIds, $filter, $showPrivate);
     }
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:15,代码来源:ContainerDebugCommand.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->container = $this->rebuild->rebuildDIC(false);
     $table = new Table($output);
     $table->setHeaders(['service-id', 'visibility']);
     $ids = $this->container->getServiceIds();
     sort($ids);
     $visibility = $input->getArgument('visibility');
     foreach ($ids as $id) {
         if ($this->container->hasDefinition($id)) {
             $this->addDefinition($id, $table, $visibility);
         }
     }
     $table->render();
 }
开发者ID:brainexe,项目名称:core,代码行数:18,代码来源:ListServicesCommand.php

示例9: testProviderIsAdded

 public function testProviderIsAdded()
 {
     $targetService = new Definition();
     $targetService->setClass('Faker\\Generator');
     $provider = $this->getMock('Acme\\Faker\\Provider\\CustomFakeDataProvider');
     $providerService = new Definition();
     $providerService->setClass(get_class($provider));
     $providerService->addTag('bazinga_faker.provider');
     $builder = new ContainerBuilder();
     $builder->addDefinitions(array('faker.generator' => $targetService, 'acme.faker.provider.custom' => $providerService));
     $builder->addCompilerPass(new AddProvidersPass());
     $builder->compile();
     $this->assertNotEmpty($builder->getServiceIds(), 'The services have been injected.');
     $this->assertNotEmpty($builder->get('faker.generator'), 'The faker.generator service has been injected.');
     $this->assertNotEmpty($builder->get('acme.faker.provider.custom'), 'The provider service has been injected.');
     /*
      * Schema:
      *
      * [0] The list of methods.
      *   [0] The name of the method to call.
      *   [1] The arguments to pass into the method call.
      *     [0] First argument to pass into the method call.
      *     ...
      */
     $targetMethodCalls = $builder->getDefinition('faker.generator')->getMethodCalls();
     $this->assertNotEmpty($targetMethodCalls, 'The faker.generator service got method calls added.');
     $this->assertEquals('addProvider', $targetMethodCalls[0][0], 'The faker.generator service got a provider added.');
     $this->assertEquals('acme.faker.provider.custom', $targetMethodCalls[0][1][0], 'The faker.generator service got the correct provider added.');
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:29,代码来源:AddProvidersPassTest.php

示例10: execute

 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $this->containerBuilder = $this->getContainerBuilder();
     if ($input->getOption('parameters')) {
         $parameters = $this->getContainerBuilder()->getParameterBag()->all();
         // Sort parameters alphabetically
         ksort($parameters);
         $this->outputParameters($output, $parameters);
         return;
     }
     $parameter = $input->getOption('parameter');
     if (null !== $parameter) {
         $output->write($this->formatParameter($this->getContainerBuilder()->getParameter($parameter)));
         return;
     }
     if ($input->getOption('tags')) {
         $this->outputTags($output, $input->getOption('show-private'));
         return;
     }
     $tag = $input->getOption('tag');
     if (null !== $tag) {
         $serviceIds = array_keys($this->containerBuilder->findTaggedServiceIds($tag));
     } else {
         $serviceIds = $this->containerBuilder->getServiceIds();
     }
     // sort so that it reads like an index of services
     asort($serviceIds);
     $name = $input->getArgument('name');
     if ($name) {
         $this->outputService($output, $name);
     } else {
         $this->outputServices($output, $serviceIds, $input->getOption('show-private'), $tag);
     }
 }
开发者ID:mesushan,项目名称:FirstRepo,代码行数:40,代码来源:ContainerDebugCommand.php

示例11: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$this->integrationExtension->isTransactionalAutoGenerateProxy()) {
         // Transactional system or auto generate proxy is disabled
         return;
     }
     $transactionalId = $this->integrationExtension->getTransactionalService();
     // Validate transactional service
     $transactionalDefinition = $container->getDefinition($transactionalId);
     $class = $transactionalDefinition->getClass();
     try {
         $class = $container->getParameterBag()->resolveValue($class);
         $refClass = new \ReflectionClass($class);
         $requiredInterface = 'FivePercent\\Component\\Transactional\\TransactionalInterface';
         if (!$refClass->implementsInterface($requiredInterface)) {
             throw new \RuntimeException(sprintf('The transactional service with class "%s" should implement %s.', $class, $requiredInterface));
         }
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf('The transactional service with id "%s" is invalid.', $transactionalId), 0, $e);
     }
     // Get all services
     $serviceIds = $container->getServiceIds();
     $directory = $container->getParameter('kernel.cache_dir') . '/transactional';
     foreach ($serviceIds as $serviceId) {
         if ($container->hasAlias($serviceId)) {
             // Not check in alias.
             continue;
         }
         $serviceDefinition = $container->getDefinition($serviceId);
         if ($serviceDefinition->isAbstract()) {
             // Not check in abstract service.
             continue;
         }
         $class = $serviceDefinition->getClass();
         $class = $container->getParameterBag()->resolveValue($class);
         if (!$class) {
             continue;
         }
         try {
             $proxyCodeGenerator = new ProxyFileGenerator($directory, $class);
         } catch (\ReflectionException $e) {
             $container->getCompiler()->addLogMessage(sprintf('%s Error with create proxy code generator for class "%s". Maybe class not found?', get_class($this), $class));
             continue;
         }
         if ($proxyCodeGenerator->needGenerate()) {
             // Generate proxy file
             $filePath = $proxyCodeGenerator->generate();
             $serviceDefinition->setClass($proxyCodeGenerator->getProxyClassName());
             // Add "__setTransactional" method call for set transactional layer
             $methodCalls = $serviceDefinition->getMethodCalls();
             array_unshift($methodCalls, ['___setTransactional', [new Reference($transactionalId)]]);
             $serviceDefinition->setMethodCalls($methodCalls);
             // Add resource for control cache
             $container->addResource(new FileResource($filePath));
             $realClassReflection = new \ReflectionClass($class);
             $container->addResource(new FileResource($realClassReflection->getFileName()));
         }
     }
 }
开发者ID:Gtvar,项目名称:FivePercent-IntegrationBundle,代码行数:62,代码来源:GenerateProxyTransactionalPass.php

示例12: testBaseSetup

 /**
  * @dataProvider getDebugModes
  */
 public function testBaseSetup($debug)
 {
     $this->container->setParameter('kernel.debug', $debug);
     $this->container->enterScope('request');
     $this->container->set('request', Request::create('/'));
     $this->container->set('kernel', $this->kernel);
     $extension = new PlatinumPixsGoogleClosureLibraryExtension();
     $extension->load(array('platinum_pixs_google_closure_library' => array('outputMode' => 'compiled', 'compilerFlags' => array('--compilation_level=ADVANCED_OPTIMIZATIONS', "--define='somevariableinside=somevalue'"), 'externs' => array("src/PlatinumPixs/TestBundle/Resources/javascript/loggly-externs.js"), 'root' => array("src/PlatinumPixs/TestBundle/Resources/javascript"))), $this->container);
     $errors = array();
     foreach ($this->container->getServiceIds() as $id) {
         try {
             $this->container->get($id);
         } catch (\Exception $e) {
             print $e->getMessage();
             $errors[$id] = $e->getMessage();
         }
     }
     self::assertEquals(array(), $errors, '');
 }
开发者ID:platinumpixs,项目名称:symfony2-google-closure-library,代码行数:22,代码来源:PlatinumPixsGoogleClosureLibraryExtensionTest.php

示例13: testDoctrineDisabledConfig

 /**
  *
  */
 public function testDoctrineDisabledConfig()
 {
     $this->extension->load([], $this->container);
     $this->extension->prepend($this->container);
     $this->assertFalse($this->container->getParameter($this->root . '.report.enabled'));
     $this->assertFalse($this->container->hasParameter($this->root . '.report.database.driver'));
     $this->assertFalse($this->container->hasParameter($this->root . '.report.database.user'));
     $this->assertFalse($this->container->hasParameter($this->root . '.report.database.password'));
     $this->assertFalse($this->container->hasParameter($this->root . '.report.database.path'));
     $this->assertCount(0, $this->container->getExtensionConfig('doctrine'));
     $this->assertNotContains($this->root . '.listener.executionreport', $this->container->getServiceIds());
 }
开发者ID:Baby-Markt,项目名称:CronBundle,代码行数:15,代码来源:BabymarktExtCronExtensionTest.php

示例14: testBasicConfigurationLoad

 public function testBasicConfigurationLoad()
 {
     $extension = new LtRedisExtension();
     $parser = new Parser();
     $config = $parser->parse($this->basicYmlConfig());
     $extension->load(array($config), $container = new ContainerBuilder());
     $services = $container->getServiceIds();
     $this->assertContains('lt_redis.connection_factory', $services);
     $this->assertContains('lt_redis.logger', $services);
     $this->assertContains('lt_redis.default', $services);
     $this->assertContains('lt_redis.default_connection', $services);
 }
开发者ID:ronnylt,项目名称:LtRedisBundle,代码行数:12,代码来源:LtRedisExtensionTest.php

示例15: getTokens

 /**
  * @param ContainerBuilder $container
  * @return string[]
  */
 private function getTokens(ContainerBuilder $container) : array
 {
     $tokens = [];
     $serviceIds = $container->getServiceIds();
     foreach ($serviceIds as $serviceId) {
         try {
             $class = $container->getDefinition($serviceId)->getClass();
             $reflection = new ReflectionClass($class);
         } catch (Exception $e) {
             continue;
         }
         $this->getTokensForService($tokens, $container, $reflection, $serviceId);
     }
     return $tokens;
 }
开发者ID:brainexe,项目名称:core,代码行数:19,代码来源:CompilerPass.php


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