Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DependencyInjection/BazingaJsTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Definition\Processor;

Expand All @@ -22,9 +22,9 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration($container->getParameter('kernel.debug'));
$config = $processor->processConfiguration($configuration, $configs);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$loader->load('controllers.xml');
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.php');
$loader->load('controllers.php');

$container
->getDefinition('bazinga.jstranslation.controller')
Expand Down
6 changes: 0 additions & 6 deletions Dumper/TranslationDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,7 @@ private function dumpTranslationsPerDomain($pattern, array $formats, $target)
{
foreach ($this->getTranslations() as $locale => $domains) {
foreach ($domains as $domain => $translations) {

$cleanedDomain = Util::cleanDomain($domain);
if ($domain !== $cleanedDomain && !in_array($cleanedDomain, $domains, true)) {
// e.g.: skip "messages+intl-icu" if "messages" exists. They will get merged after.
continue;
}

$renderContext = array(
'translations' => array($locale => $this->filterTranslationsByDomain($domains, $cleanedDomain)),
'include_config' => false,
Expand Down
26 changes: 26 additions & 0 deletions Resources/config/controllers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Bazinga\Bundle\JsTranslationBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container->parameters()
->set('bazinga.jstranslation.controller.class', Controller::class);

$services = $container->services();

$services->set('bazinga.jstranslation.controller', param('bazinga.jstranslation.controller.class'))
->public()
->args([
service('translator'),
service('twig'),
service('bazinga.jstranslation.translation_finder'),
param('kernel.cache_dir') . '/bazinga-js-translation',
param('kernel.debug'),
null, // fallback (locale)
null, // default domain
null, // http cache time
]);
};
22 changes: 0 additions & 22 deletions Resources/config/controllers.xml

This file was deleted.

42 changes: 42 additions & 0 deletions Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Bazinga\Bundle\JsTranslationBundle\Command\DumpCommand;
use Bazinga\Bundle\JsTranslationBundle\Dumper\TranslationDumper;
use Bazinga\Bundle\JsTranslationBundle\Finder\TranslationFinder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container->parameters()
->set('bazinga.jstranslation.translation_finder.class', TranslationFinder::class)
->set('bazinga.jstranslation.translation_dumper.class', TranslationDumper::class);

$services = $container->services();

$services->set('bazinga.jstranslation.translation_finder', param('bazinga.jstranslation.translation_finder.class'))
->public()
->args([
[], // all resource files paths from the framework bundle
]);

$services->set('bazinga.jstranslation.translation_dumper', param('bazinga.jstranslation.translation_dumper.class'))
->public()
->args([
service('twig'),
service('bazinga.jstranslation.translation_finder'),
service('filesystem'),
null, // fallback (locale)
null, // default domain
null, // active locales
null, // active domains
]);

$services->set('bazinga.jstranslation.dump_command', DumpCommand::class)
->public()
->args([
service('bazinga.jstranslation.translation_dumper'),
param('kernel.project_dir'),
])
->tag('console.command', ['command' => 'bazinga:js-translation:dump']);
};
30 changes: 0 additions & 30 deletions Resources/config/services.xml

This file was deleted.