|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace libphonenumber\buildtools\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use libphonenumber\buildtools\BuildMetadataPHPFromXml; |
|
6
|
|
|
use Symfony\Component\Console\Command\Command; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
10
|
|
|
|
|
11
|
|
|
class BuildMetadataPHPFromXMLCommand extends Command |
|
12
|
|
|
{ |
|
13
|
|
|
protected function configure() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->setName('BuildMetadataPHPFromXML'); |
|
16
|
|
|
$this->setDescription('Generate phone metadata data files'); |
|
17
|
|
|
$this->setDefinition( |
|
18
|
|
|
array( |
|
19
|
|
|
new InputArgument('InputFile', InputArgument::REQUIRED, 'The input file containing phone number metadata in XML format.'), |
|
20
|
|
|
new InputArgument('OutputDirectory', InputArgument::REQUIRED, 'The output source directory to store phone number metadata (one file per region) and the country code to region code mapping file'), |
|
21
|
|
|
new InputArgument('DataPrefix', InputArgument::REQUIRED, 'The start of the filename to store the files (e.g. dataPrefix_GB.php'), |
|
22
|
|
|
new InputArgument('MappingClass', InputArgument::REQUIRED, 'The name of the mapping class generated'), |
|
23
|
|
|
new InputArgument('MappingClassLocation', InputArgument::REQUIRED, 'The directory where the mapping class is stored'), |
|
24
|
|
|
new InputArgument('LiteBuild', InputArgument::OPTIONAL, 'Whether to generate the lite-version of the metadata. When set to true, certain metadata will be omitted. AT this moment, example numbers information is omitted', false), |
|
25
|
|
|
) |
|
26
|
|
|
); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
30
|
|
|
{ |
|
31
|
|
|
$build = new BuildMetadataPHPFromXml(); |
|
32
|
|
|
$build->start( |
|
33
|
|
|
$input->getArgument('InputFile'), |
|
34
|
|
|
$input->getArgument('OutputDirectory'), |
|
35
|
|
|
$input->getArgument('DataPrefix'), |
|
36
|
|
|
$input->getArgument('MappingClass'), |
|
37
|
|
|
$input->getArgument('MappingClassLocation'), |
|
38
|
|
|
($input->getArgument('LiteBuild') == 'true') ? true : false |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
return 0; |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|