getServiceIds() public method

Gets all service ids.
public getServiceIds ( ) : array
return array An array of all defined service ids
 public function testConfig()
 {
     $this->createFullConfiguration();
     $this->assertParameter('foo_key', 'freshdesk_api_key');
     $this->assertParameter('bar_domain', 'freshdesk_domain');
     $this->assertContains('freshdesk', $this->containerBuilder->getServiceIds());
 }
 /**
  * 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;
 }
 /**
  * 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));
 }
Example #4
0
 /**
  * @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);
     }
 }
 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);
 }
Example #6
0
 /**
  * {@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()));
         }
     }
 }
 /**
  * @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);
     }
 }
Example #8
0
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     $this->containerBuilder = $this->getContainerBuilder();
     $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'));
     }
 }
Example #9
0
 /**
  * {@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();
 }
 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.');
 }
 /**
  * {@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);
     }
 }
 /**
  * {@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()));
         }
     }
 }
 /**
  * @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, '');
 }
 /**
  *
  */
 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());
 }
 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);
 }
Example #16
0
 /**
  * @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;
 }
 private function processTaggedControllers(ContainerBuilder $containerBuilder)
 {
     $controllerClasses = [];
     $taggedControllerServices = $containerBuilder->findTaggedServiceIds('controller');
     foreach ($taggedControllerServices as $serviceName => $params) {
         $controllerClasses[$serviceName] = $containerBuilder->getDefinition($serviceName)->getClass();
     }
     $allServices = $containerBuilder->getServiceIds();
     foreach ($allServices as $serviceName) {
         if (substr($serviceName, -11) === '_controller') {
             $controllerClasses[$serviceName] = $containerBuilder->getDefinition($serviceName)->getClass();
         }
     }
     /** @var Definition $controllerRoutingLoaderDefinition */
     $controllerRoutingLoaderDefinition = $containerBuilder->getDefinition('kutny.no_bundle_controllers.controller_routing_loader');
     $controllerRoutingLoaderDefinition->addMethodCall('setControllerClasses', array($controllerClasses));
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 protected function describeContainerServices(ContainerBuilder $builder, array $options = array())
 {
     $showPrivate = isset($options['show_private']) && $options['show_private'];
     $title = $showPrivate ? 'Public and private services' : 'Public services';
     if (isset($options['tag'])) {
         $title .= ' with tag `' . $options['tag'] . '`';
     }
     $this->write($title . "\n" . str_repeat('=', strlen($title)));
     $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
     $showPrivate = isset($options['show_private']) && $options['show_private'];
     $services = array('definitions' => array(), 'aliases' => array(), 'services' => array());
     foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
         $service = $this->resolveServiceDefinition($builder, $serviceId);
         if ($service instanceof Alias) {
             $services['aliases'][$serviceId] = $service;
         } elseif ($service instanceof Definition) {
             if ($showPrivate || $service->isPublic()) {
                 $services['definitions'][$serviceId] = $service;
             }
         } else {
             $services['services'][$serviceId] = $service;
         }
     }
     if (!empty($services['definitions'])) {
         $this->write("\n\nDefinitions\n-----------\n");
         foreach ($services['definitions'] as $id => $service) {
             $this->write("\n");
             $this->describeContainerDefinition($service, array('id' => $id));
         }
     }
     if (!empty($services['aliases'])) {
         $this->write("\n\nAliases\n-------\n");
         foreach ($services['aliases'] as $id => $service) {
             $this->write("\n");
             $this->describeContainerAlias($service, array('id' => $id));
         }
     }
     if (!empty($services['services'])) {
         $this->write("\n\nServices\n--------\n");
         foreach ($services['services'] as $id => $service) {
             $this->write("\n");
             $this->write(sprintf('- `%s`: `%s`', $id, get_class($service)));
         }
     }
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 protected function describeContainerServices(ContainerBuilder $builder, array $options = array())
 {
     $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
     $showPrivate = isset($options['show_private']) && $options['show_private'];
     $data = array('definitions' => array(), 'aliases' => array(), 'services' => array());
     foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
         $service = $this->resolveServiceDefinition($builder, $serviceId);
         if ($service instanceof Alias) {
             $data['aliases'][$serviceId] = $this->getContainerAliasData($service);
         } elseif ($service instanceof Definition) {
             if ($showPrivate || $service->isPublic()) {
                 $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service);
             }
         } else {
             $data['services'][$serviceId] = get_class($service);
         }
     }
     $this->writeData($data, $options);
 }
 /**
  * Generate full \Service class, with all services as methods
  *
  * @throws ServicesNotFoundException
  */
 protected function generateFullServicesShortcuts()
 {
     $cachedFile = $this->container->getParameter('debug.container.dump');
     if (!is_file($cachedFile)) {
         throw new ServicesNotFoundException('Service list not found. Parameter "debug.container.dump" doesn\'t exists. Try to clear cache and try again.');
     }
     $builder = new ContainerBuilder();
     $loader = new XmlFileLoader($builder, new FileLocator());
     $loader->load($cachedFile);
     $generator = new ClassGenerator();
     $generator->setExtractUses(false);
     $generator->setClassName('Service');
     foreach ($builder->getServiceIds() as $id) {
         if (preg_match('/^[a-zA-Z]{1}/', $id) === false) {
             continue;
         } else {
             if ($builder->hasDefinition($id)) {
                 $definition = $builder->getDefinition($id);
             } else {
                 if ($builder->hasAlias($id)) {
                     $alias = $builder->getAlias($id);
                     $definition = $builder->getDefinition($alias);
                 } else {
                     continue;
                 }
             }
         }
         if ($definition->isPublic()) {
             $method = new Method(str_replace('.', '__', $id));
             $method->setIsStatic(true);
             $method->setReturn($this->getServiceClass($id, $definition));
             $method->addLine('return _service(\'' . $id . '\');');
             $generator->addMethod($method);
         }
     }
     $generator->write($this->getFileName());
 }
Example #21
0
 /**
  * Gets all service ids.
  *
  * Wrapper for ContainerBuilder::getServiceIds method.
  *
  * @return array An array of all defined service ids
  */
 public function getServiceIds()
 {
     return parent::getServiceIds();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $srcFinder = new Finder();
     $cmsFinder = new Finder();
     $cachedFile = $this->getContainer()->getParameter('debug.container.dump');
     $container = new ContainerBuilder();
     $loader = new XmlFileLoader($container, new FileLocator());
     $loader->load($cachedFile);
     $services = $container->getServiceIds();
     $sites = $em->getRepository('SymbioOrangeGatePageBundle:Site')->findAll();
     $tokens = [];
     // find tokens in src files
     $srcFinder->files()->in($this->getContainer()->get('kernel')->getRootDir() . '/../src')->name('*.php')->name('*.html.twig');
     foreach ($srcFinder as $file) {
         $fileContent = file_get_contents($file->getRealPath());
         foreach ($sites as $site_key => $site) {
             $add = false;
             $tokenSite = null;
             $tokenName = null;
             if (preg_match('/\'' . strtolower($site->getSlug()) . '\\.(.*)\'/', $fileContent, $matches) || preg_match('/\\"' . strtolower($site->getSlug()) . '\\.(.*)\\"/', $fileContent, $matches)) {
                 $tokenSite = $site;
                 $tokenName = str_replace("\"", '', str_replace('\'', '', $matches[0]));
                 $add = true;
             } elseif (preg_match('/\'orangegate\\.(.*)\'/', $fileContent, $matches) || preg_match('/\\"orangegate\\.(.*)\\"/', $fileContent, $matches)) {
                 $tokenName = str_replace("\"", '', str_replace('\'', '', $matches[0]));
                 $add = true;
             }
             if ($add && !in_array($tokenName, $services) && !in_array($tokenName, $tokens)) {
                 $catalogueName = "";
                 if (strpos($tokenName, '|trans') !== false) {
                     $catalogueName = substr($tokenName, strrpos($tokenName, '(') + 1, strlen($tokenName));
                     if (strpos($catalogueName, ',') !== false) {
                         $catalogueName = substr($catalogueName, strrpos($catalogueName, ',') + 1, strlen($catalogueName));
                     }
                     $tokenName = substr($tokenName, 0, strpos($tokenName, '|trans'));
                 }
                 if (strpos($tokenName, ',') !== false) {
                     $tokenName = str_replace(' ', '', $tokenName);
                     $catalogueName = substr($tokenName, strrpos($tokenName, ',') + 1, strlen($tokenName));
                     $tokenName = substr($tokenName, 0, strpos($tokenName, ','));
                 }
                 $catalogueName = $catalogueName == $tokenName || !$catalogueName ? self::DEFAULT_CATALOGUE : $catalogueName;
                 if (strpos($tokenName, '%') === false) {
                     $catalogue = $em->getRepository("SymbioOrangeGateTranslationBundle:LanguageCatalogue")->findOneByName($catalogueName);
                     if (!$catalogue) {
                         $catalogue = new LanguageCatalogue();
                         $catalogue->setName($catalogueName);
                         $em->persist($catalogue);
                     }
                     if (!$em->getRepository('SymbioOrangeGateTranslationBundle:LanguageToken')->findOneBy(['token' => $tokenName])) {
                         $tokens[] = $tokenName;
                         $token = new \Symbio\OrangeGate\TranslationBundle\Entity\LanguageToken();
                         $token->setToken($tokenName);
                         $token->setCatalogue($catalogue);
                         $token->setSite($tokenSite);
                         $em->persist($token);
                     }
                 }
             }
         }
     }
     //find tokens in cms bundles
     $cmsFinder->files()->in($this->getContainer()->get('kernel')->getRootDir() . '/../vendor/symbio')->notName('*.json');
     foreach ($cmsFinder as $file) {
         $fileContent = file_get_contents($file->getRealPath());
         if (preg_match('/\'orangegate\\.(.*)\'/', $fileContent, $matches) || preg_match('/\\"orangegate\\.(.*)\\"/', $fileContent, $matches)) {
             $tokenName = str_replace("\"", '', str_replace('\'', '', $matches[0]));
             if (!in_array($tokenName, $services) && !in_array($tokenName, $tokens)) {
                 $catalogueName = "";
                 if (strpos($tokenName, '|trans') !== false) {
                     $tokenName = str_replace(' ', '', $tokenName);
                     $catalogueName = substr($tokenName, strrpos($tokenName, '(') + 1, strlen($tokenName));
                     if (strpos($catalogueName, ',') !== false) {
                         $catalogueName = substr($catalogueName, strrpos($catalogueName, ',') + 1, strlen($catalogueName));
                     }
                     $tokenName = substr($tokenName, 0, strpos($tokenName, '|trans'));
                 }
                 if (strpos($tokenName, ',') !== false) {
                     $tokenName = str_replace(' ', '', $tokenName);
                     $catalogueName = substr($tokenName, strrpos($tokenName, ',') + 1, strlen($tokenName));
                     $tokenName = substr($tokenName, 0, strpos($tokenName, ','));
                 }
                 $catalogueName = $catalogueName == $tokenName || !$catalogueName ? self::DEFAULT_CATALOGUE : $catalogueName;
                 if (strpos($tokenName, '%') === false) {
                     $catalogue = $em->getRepository("SymbioOrangeGateTranslationBundle:LanguageCatalogue")->findOneByName($catalogueName);
                     if (!$catalogue) {
                         $catalogue = new LanguageCatalogue();
                         $catalogue->setName($catalogueName);
                         $em->persist($catalogue);
                     }
                     if (!$em->getRepository('SymbioOrangeGateTranslationBundle:LanguageToken')->findOneBy(['catalogue' => $catalogue, 'token' => $tokenName])) {
                         $tokens[] = $tokenName;
                         $token = new \Symbio\OrangeGate\TranslationBundle\Entity\LanguageToken();
                         $token->setToken($tokenName);
                         $token->setCatalogue($catalogue);
                         $token->setSite(null);
                         $em->persist($token);
                     }
                 }
             }
         }
     }
     $em->flush();
     foreach ($tokens as $token) {
         $output->writeln('---> Token "' . $token . '" successfully inserted.');
     }
     $output->writeln('Operation complete!');
 }
 private function findServiceIdsContaining(ContainerBuilder $builder, $name)
 {
     $serviceIds = $builder->getServiceIds();
     $foundServiceIds = array();
     $name = strtolower($name);
     foreach ($serviceIds as $serviceId) {
         if (false === strpos($serviceId, $name)) {
             continue;
         }
         $foundServiceIds[] = $serviceId;
     }
     return $foundServiceIds;
 }
 public function getServiceIds()
 {
     return $this->delegate->getServiceIds();
 }
 public function testConfig()
 {
     $this->createFullConfiguration();
     $this->assertParameter('foo_key', 'bugherd_api_key');
     $this->assertContains('bugherd', $this->containerBuilder->getServiceIds());
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 protected function describeContainerServices(ContainerBuilder $builder, array $options = array())
 {
     $showPrivate = isset($options['show_private']) && $options['show_private'];
     $showTag = isset($options['tag']) ? $options['tag'] : null;
     if ($showPrivate) {
         $title = 'Symfony Container Public and Private Services';
     } else {
         $title = 'Symfony Container Public Services';
     }
     if ($showTag) {
         $title .= sprintf(' Tagged with "%s" Tag', $options['tag']);
     }
     $options['output']->title($title);
     $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
     $maxTags = array();
     foreach ($serviceIds as $key => $serviceId) {
         $definition = $this->resolveServiceDefinition($builder, $serviceId);
         if ($definition instanceof Definition) {
             // filter out private services unless shown explicitly
             if (!$showPrivate && !$definition->isPublic()) {
                 unset($serviceIds[$key]);
                 continue;
             }
             if ($showTag) {
                 $tags = $definition->getTag($showTag);
                 foreach ($tags as $tag) {
                     foreach ($tag as $key => $value) {
                         if (!isset($maxTags[$key])) {
                             $maxTags[$key] = strlen($key);
                         }
                         if (strlen($value) > $maxTags[$key]) {
                             $maxTags[$key] = strlen($value);
                         }
                     }
                 }
             }
         }
     }
     $tagsCount = count($maxTags);
     $tagsNames = array_keys($maxTags);
     $tableHeaders = array_merge(array('Service ID'), $tagsNames, array('Class name'));
     $tableRows = array();
     foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
         $definition = $this->resolveServiceDefinition($builder, $serviceId);
         if ($definition instanceof Definition) {
             if ($showTag) {
                 foreach ($definition->getTag($showTag) as $key => $tag) {
                     $tagValues = array();
                     foreach ($tagsNames as $tagName) {
                         $tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : '';
                     }
                     if (0 === $key) {
                         $tableRows[] = array_merge(array($serviceId), $tagValues, array($definition->getClass()));
                     } else {
                         $tableRows[] = array_merge(array('  "'), $tagValues, array(''));
                     }
                 }
             } else {
                 $tableRows[] = array($serviceId, $definition->getClass());
             }
         } elseif ($definition instanceof Alias) {
             $alias = $definition;
             $tableRows[] = array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
         } else {
             // we have no information (happens with "service_container")
             $tableRows[] = array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
         }
     }
     $options['output']->table($tableHeaders, $tableRows);
 }
Example #27
0
 /**
  * {@inheritdoc}
  */
 protected function describeContainerServices(ContainerBuilder $builder, array $options = array())
 {
     $showPrivate = isset($options['show_private']) && $options['show_private'];
     $showTag = isset($options['tag']) ? $options['tag'] : null;
     if ($showPrivate) {
         $label = '<comment>Public</comment> and <comment>private</comment> services';
     } else {
         $label = '<comment>Public</comment> services';
     }
     if ($showTag) {
         $label .= ' with tag <info>' . $options['tag'] . '</info>';
     }
     $this->writeText($this->formatSection('container', $label) . "\n", $options);
     $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
     $maxTags = array();
     foreach ($serviceIds as $key => $serviceId) {
         $definition = $this->resolveServiceDefinition($builder, $serviceId);
         if ($definition instanceof Definition) {
             // filter out private services unless shown explicitly
             if (!$showPrivate && !$definition->isPublic()) {
                 unset($serviceIds[$key]);
                 continue;
             }
             if ($showTag) {
                 $tags = $definition->getTag($showTag);
                 foreach ($tags as $tag) {
                     foreach ($tag as $key => $value) {
                         if (!isset($maxTags[$key])) {
                             $maxTags[$key] = strlen($key);
                         }
                         if (strlen($value) > $maxTags[$key]) {
                             $maxTags[$key] = strlen($value);
                         }
                     }
                 }
             }
         }
     }
     $tagsCount = count($maxTags);
     $tagsNames = array_keys($maxTags);
     $table = new Table($this->getOutput());
     $table->setStyle('compact');
     $table->setHeaders(array_merge(array('Service ID'), $tagsNames, array('Class name')));
     foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
         $definition = $this->resolveServiceDefinition($builder, $serviceId);
         if ($definition instanceof Definition) {
             if ($showTag) {
                 foreach ($definition->getTag($showTag) as $key => $tag) {
                     $tagValues = array();
                     foreach ($tagsNames as $tagName) {
                         $tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : "";
                     }
                     if (0 === $key) {
                         $table->addRow(array_merge(array($serviceId), $tagValues, array($definition->getClass())));
                     } else {
                         $table->addRow(array_merge(array('  "'), $tagValues, array('')));
                     }
                 }
             } else {
                 $table->addRow(array($serviceId, $definition->getClass()));
             }
         } elseif ($definition instanceof Alias) {
             $alias = $definition;
             $table->addRow(array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, "") : array()));
         } else {
             // we have no information (happens with "service_container")
             $table->addRow(array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, "") : array()));
         }
     }
     $this->renderTable($table);
 }
Example #28
0
 /**
  * @param ContainerBuilder $builder
  * @param string|null      $tag
  * @param bool             $showPrivate
  *
  * @return \DOMDocument
  */
 private function getContainerServicesDocument(ContainerBuilder $builder, $tag = null, $showPrivate = false)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($containerXML = $dom->createElement('container'));
     $serviceIds = $tag ? array_keys($builder->findTaggedServiceIds($tag)) : $builder->getServiceIds();
     foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
         $service = $this->resolveServiceDefinition($builder, $serviceId);
         if ($service instanceof Definition && !($showPrivate || $service->isPublic())) {
             continue;
         }
         $serviceXML = $this->getContainerServiceDocument($service, $serviceId);
         $containerXML->appendChild($containerXML->ownerDocument->importNode($serviceXML->childNodes->item(0), true));
     }
     return $dom;
 }
 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
  */
 public function testGetServiceIds()
 {
     $builder = new ContainerBuilder();
     $builder->register('foo', 'stdClass');
     $builder->bar = $bar = new \stdClass();
     $builder->register('bar', 'stdClass');
     $this->assertEquals(array('foo', 'bar', 'service_container'), $builder->getServiceIds(), '->getServiceIds() returns all defined service ids');
 }
 /**
  * Test related method
  */
 public function testLoad()
 {
     $this->extension->load($this->configs, $this->containerBuilder);
     $this->assertGreaterThanOrEqual(1, $this->containerBuilder->getServiceIds());
 }