Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
created

Controller/TranslatorCommandController.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\TranslatorBundle\Controller;
4
5
use Kunstmaan\AdminBundle\FlashMessages\FlashTypes;
6
use Kunstmaan\TranslatorBundle\Model\Export\ExportCommand;
7
use Kunstmaan\TranslatorBundle\Model\Import\ImportCommand;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10
use Symfony\Component\HttpFoundation\RedirectResponse;
11
12
class TranslatorCommandController extends Controller
13
{
14
    /**
15
     * @Route("/clear-cache", name="KunstmaanTranslatorBundle_command_clear_cache")
16
     */
17
    public function clearCacheAction()
18
    {
19
20
        $this->get('kunstmaan_translator.service.translator.resource_cacher')->flushCache();
21
        $this->addFlash(
22
            FlashTypes::SUCCESS,
23
            $this->get('translator')->trans('kuma_translator.command.clear.flash.success')
24
        );
25
26
        return new RedirectResponse($this->generateUrl('KunstmaanTranslatorBundle_settings_translations'));
27
    }
28
29
    /**
30
     * @Route("/import", name="KunstmaanTranslatorBundle_command_import")
31
     */
32 View Code Duplication
    public function importAction()
33
    {
34
        $importCommand = new ImportCommand();
35
        $importCommand
36
            ->setForce(false)
37
            ->setDefaultBundle($this->getParameter('kuma_translator.default_bundle'))
38
            ->setBundles($this->getParameter('kuma_translator.bundles'))
39
            ->setGlobals(true);
40
41
        $this->get('kunstmaan_translator.service.importer.command_handler')->executeImportCommand($importCommand);
42
43
        $this->addFlash(
44
            FlashTypes::SUCCESS,
45
            $this->get('translator')->trans('kuma_translator.command.import.flash.success')
46
        );
47
48
        return new RedirectResponse($this->generateUrl('KunstmaanTranslatorBundle_settings_translations'));
49
    }
50
51
    /**
52
     * @Route("/import-forced", name="KunstmaanTranslatorBundle_command_import_forced")
53
     */
54 View Code Duplication
    public function importForcedAction()
55
    {
56
        $importCommand = new ImportCommand();
57
        $importCommand
58
            ->setForce(true)
59
            ->setDefaultBundle($this->getParameter('kuma_translator.default_bundle'))
60
            ->setBundles($this->getParameter('kuma_translator.bundles'))
61
            ->setGlobals(false);
62
63
        $this->get('kunstmaan_translator.service.importer.command_handler')->executeImportCommand($importCommand);
64
65
        $this->addFlash(
66
            FlashTypes::SUCCESS,
67
            $this->get('translator')->trans('kuma_translator.command.import.flash.force_success')
68
        );
69
70
        return new RedirectResponse($this->generateUrl('KunstmaanTranslatorBundle_settings_translations'));
71
    }
72
73
    /**
74
     * @Route("/export", name="KunstmaanTranslatorBundle_command_export")
75
     */
76
    public function exportAction()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
77
    {
78
        $locales = $this->getParameter('kuma_translator.managed_locales');
79
        $exportCommand = new ExportCommand();
80
        $exportCommand
81
            ->setLocales($locales)
82
            ->setFormat('csv');
83
84
        $response = $this->get('kunstmaan_translator.service.exporter.command_handler')->executeExportCSVCommand($exportCommand);
85
86
        return $response;
87
    }
88
}
89