Skip to content
Open
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
14 changes: 8 additions & 6 deletions Command/ImportTranslationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ protected function execute(InputInterface $input, OutputInterface $output)

$bundleName = $this->input->getArgument('bundle');
if ($bundleName) {
$bundle = $this->getApplication()->getKernel()->getBundle($bundleName);
$bundle = $this
->getContainer()->get('kernel')
->getBundle($bundleName);

if (Kernel::VERSION_ID < 40000 && null !== $bundle->getParent()) {
// due to symfony's bundle inheritance if a bundle has a parent it is fetched first.
// so we tell getBundle to NOT fetch the first if a parent is present
$bundles = $this->getApplication()->getKernel()->getBundle($bundle->getParent(), false);
$bundles = $this->getContainer()->get('kernel')->getBundle($bundle->getParent(), false);
$bundle = $bundles[1];
$this->output->writeln('<info>Using: ' . $bundle->getName() . ' as bundle to lookup translations files for.');
}
Expand Down Expand Up @@ -199,7 +201,7 @@ protected function importComponentTranslationFiles(array $locales, array $domain
*/
protected function importAppTranslationFiles(array $locales, array $domains)
{
$finder = $this->findTranslationsFiles($this->getApplication()->getKernel()->getRootDir(), $locales, $domains);
$finder = $this->findTranslationsFiles($this->getContainer()->getParameter('kernel.root_dir'), $locales, $domains);
$this->importTranslationFiles($finder);
}

Expand All @@ -212,7 +214,7 @@ protected function importAppTranslationFiles(array $locales, array $domains)
*/
protected function importBundlesTranslationFiles(array $locales, array $domains, $global = false)
{
$bundles = $this->getApplication()->getKernel()->getBundles();
$bundles = $this->getContainer()->get('kernel')->getBundles();

foreach ($bundles as $bundle) {
$this->importBundleTranslationFiles($bundle, $locales, $domains, $global);
Expand All @@ -231,7 +233,7 @@ protected function importBundleTranslationFiles(BundleInterface $bundle, $locale
{
$path = $bundle->getPath();
if ($global) {
$path = $this->getApplication()->getKernel()->getRootDir() . '/Resources/' . $bundle->getName() . '/translations';
$path = $this->getContainer()->getParameter('kernel.root_dir') . '/Resources/' . $bundle->getName() . '/translations';
$this->output->writeln('<info>*** Importing ' . $bundle->getName() . '`s translation files from ' . $path . ' ***</info>');
}

Expand Down Expand Up @@ -285,7 +287,7 @@ protected function findTranslationsFiles($path, array $locales, array $domains,
}

if (true === $autocompletePath) {
$dir = (0 === strpos($path, $this->getApplication()->getKernel()->getRootDir() . '/Resources')) ? $path : $path . '/Resources/translations';
$dir = (0 === strpos($path, $this->getContainer()->getParameter('kernel.root_dir') . '/Resources')) ? $path : $path . '/Resources/translations';
} else {
$dir = $path;
}
Expand Down