1111
1212namespace Translation \Bundle \Command ;
1313
14- use Symfony \Bundle \ FrameworkBundle \Command \ContainerAwareCommand ;
14+ use Symfony \Component \ Console \Command \Command ;
1515use Symfony \Component \Console \Input \InputArgument ;
1616use Symfony \Component \Console \Input \InputInterface ;
1717use Symfony \Component \Console \Input \InputOption ;
1818use Symfony \Component \Console \Output \OutputInterface ;
1919use Symfony \Component \Console \Style \SymfonyStyle ;
2020use Symfony \Component \Finder \Finder ;
21+ use Translation \Bundle \Catalogue \CatalogueCounter ;
22+ use Translation \Bundle \Catalogue \CatalogueFetcher ;
23+ use Translation \Bundle \Catalogue \CatalogueWriter ;
2124use Translation \Bundle \Model \Configuration ;
25+ use Translation \Bundle \Service \ConfigurationManager ;
26+ use Translation \Bundle \Service \Importer ;
2227use Translation \Extractor \Model \Error ;
2328
2429/**
2530 * @author Tobias Nyholm <tobias.nyholm@gmail.com>
2631 */
27- class ExtractCommand extends ContainerAwareCommand
32+ class ExtractCommand extends Command
2833{
2934 use BundleTrait;
3035
36+ protected static $ defaultName = 'translation:extract ' ;
37+
38+ /**
39+ * @var CatalogueFetcher
40+ */
41+ private $ catalogueFetcher ;
42+
43+ /**
44+ * @var CatalogueWriter
45+ */
46+ private $ catalogueWriter ;
47+
48+ /**
49+ * @var CatalogueCounter
50+ */
51+ private $ catalogueCounter ;
52+
53+ /**
54+ * @var Importer
55+ */
56+ private $ importer ;
57+
58+ /**
59+ * @var ConfigurationManager
60+ */
61+ private $ configurationManager ;
62+
63+ /**
64+ * @param CatalogueFetcher $catalogueFetcher
65+ * @param CatalogueWriter $catalogueWriter
66+ * @param CatalogueCounter $catalogueCounter
67+ * @param Importer $importer
68+ * @param ConfigurationManager $configurationManager
69+ */
70+ public function __construct (
71+ CatalogueFetcher $ catalogueFetcher ,
72+ CatalogueWriter $ catalogueWriter ,
73+ CatalogueCounter $ catalogueCounter ,
74+ Importer $ importer ,
75+ ConfigurationManager $ configurationManager
76+ ) {
77+ $ this ->catalogueFetcher = $ catalogueFetcher ;
78+ $ this ->catalogueWriter = $ catalogueWriter ;
79+ $ this ->catalogueCounter = $ catalogueCounter ;
80+ $ this ->importer = $ importer ;
81+ $ this ->configurationManager = $ configurationManager ;
82+
83+ parent ::__construct ();
84+ }
85+
3186 protected function configure ()
3287 {
3388 $ this
34- ->setName (' translation:extract ' )
89+ ->setName (self :: $ defaultName )
3590 ->setDescription ('Extract translations from source code. ' )
3691 ->addArgument ('configuration ' , InputArgument::OPTIONAL , 'The configuration to use ' , 'default ' )
3792 ->addArgument ('locale ' , InputArgument::OPTIONAL , 'The locale ot use. If omitted, we use all configured locales. ' , false )
@@ -42,35 +97,28 @@ protected function configure()
4297
4398 protected function execute (InputInterface $ input , OutputInterface $ output )
4499 {
45- $ container = $ this ->getContainer ();
46- $ importer = $ container ->get ('php_translation.importer ' );
47- $ config = $ container ->get ('php_translation.configuration_manager ' )
48- ->getConfiguration ($ input ->getArgument ('configuration ' ));
100+ $ config = $ this ->configurationManager ->getConfiguration ($ input ->getArgument ('configuration ' ));
49101
50102 $ locales = [];
51103 if ($ inputLocale = $ input ->getArgument ('locale ' )) {
52104 $ locales = [$ inputLocale ];
53105 }
54106
55- $ catalogues = $ container ->get ('php_translation.catalogue_fetcher ' )
56- ->getCatalogues ($ config , $ locales );
57-
107+ $ catalogues = $ this ->catalogueFetcher ->getCatalogues ($ config , $ locales );
58108 $ this ->configureBundleDirs ($ input , $ config );
59109 $ finder = $ this ->getConfiguredFinder ($ config );
60110
61- $ result = $ importer ->extractToCatalogues ($ finder , $ catalogues , [
111+ $ result = $ this -> importer ->extractToCatalogues ($ finder , $ catalogues , [
62112 'blacklist_domains ' => $ config ->getBlacklistDomains (),
63113 'whitelist_domains ' => $ config ->getWhitelistDomains (),
64114 'project_root ' => $ config ->getProjectRoot (),
65115 ]);
66116 $ errors = $ result ->getErrors ();
67117
68- $ container ->get ('php_translation.catalogue_writer ' )
69- ->writeCatalogues ($ config , $ result ->getMessageCatalogues ());
118+ $ this ->catalogueWriter ->writeCatalogues ($ config , $ result ->getMessageCatalogues ());
70119
71- $ catalogueCounter = $ container ->get ('php_translation.catalogue_counter ' );
72- $ definedBefore = $ catalogueCounter ->getNumberOfDefinedMessages ($ catalogues [0 ]);
73- $ definedAfter = $ catalogueCounter ->getNumberOfDefinedMessages ($ result ->getMessageCatalogues ()[0 ]);
120+ $ definedBefore = $ this ->catalogueCounter ->getNumberOfDefinedMessages ($ catalogues [0 ]);
121+ $ definedAfter = $ this ->catalogueCounter ->getNumberOfDefinedMessages ($ result ->getMessageCatalogues ()[0 ]);
74122
75123 /*
76124 * Print results
0 commit comments