1 | <?php |
||
33 | class Update extends Command |
||
34 | { |
||
35 | protected function configure() |
||
36 | { |
||
37 | $this |
||
38 | ->setName('update') |
||
39 | ->setDescription('Update the parser data') |
||
40 | ->addOption( |
||
41 | 'dir', |
||
42 | null, |
||
43 | InputArgument::OPTIONAL, |
||
44 | 'Directory to save parser data in (sub directory will be generated automatically).' |
||
45 | ) |
||
46 | ->addOption( |
||
47 | 'force', |
||
48 | null, |
||
49 | InputOption::VALUE_NONE, |
||
50 | 'Flag to force an update although it seems to be unnecessary.' |
||
51 | ) |
||
52 | ->addOption( |
||
53 | 'ini-php', |
||
54 | null, |
||
55 | InputOption::VALUE_NONE, |
||
56 | 'Will use the settings of the browscap directive in the php.ini file for the update.' |
||
57 | ) |
||
58 | ->addOption( |
||
59 | 'ini-load', |
||
60 | null, |
||
61 | InputOption::VALUE_OPTIONAL, |
||
62 | 'Will download the parser data (of the given type - "lite", "full" or "standard") for the update. ' . |
||
63 | 'If no type set, the "standard" type is used.' |
||
64 | ) |
||
65 | ->addOption( |
||
66 | 'ini-file', |
||
67 | null, |
||
68 | InputOption::VALUE_REQUIRED, |
||
69 | 'Will use the defined browscap ini-file for the update.' |
||
70 | ) |
||
71 | ->addOption( |
||
72 | 'filter-allowed', |
||
73 | null, |
||
74 | InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
||
75 | 'Sets a filter to define allowed properties when generating the data. Other properties will be ignored.' |
||
76 | ) |
||
77 | ->addOption( |
||
78 | 'filter-disallowed', |
||
79 | null, |
||
80 | InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
||
81 | 'Sets a filter to define disallowed properties when generating the data. Other properties are allowed.' |
||
82 | ) |
||
83 | ; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param InputInterface $input |
||
88 | * @param OutputInterface $output |
||
89 | * |
||
90 | * @throws UnexpectedValueException |
||
91 | */ |
||
92 | protected function interact(InputInterface $input, OutputInterface $output) |
||
93 | { |
||
94 | parent::interact($input, $output); |
||
95 | |||
96 | if (((int)$input->getOption('ini-php') + (int)$input->getOption('ini-load') + (int)$input->getOption('ini-file')) > 1) { |
||
97 | throw new UnexpectedValueException('Please use only one --ini-* option to set the data source.'); |
||
98 | } |
||
99 | if (((count($input->getOption('filter-allowed')) > 0) + (count($input->getOption('filter-disallowed')) > 0)) > 1) { |
||
100 | throw new UnexpectedValueException('Please use only one --filter-* option for the data source.'); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @param InputInterface $input |
||
106 | * @param OutputInterface $output |
||
107 | * |
||
108 | * @return int|null|void |
||
109 | * @throws ParserConfigurationException |
||
110 | * @throws ParserRuntimeException |
||
111 | * @throws SourceConditionNotSatisfiedException |
||
112 | * @throws SourceUnavailableException |
||
113 | * @throws UnexpectedValueException |
||
114 | */ |
||
115 | protected function execute(InputInterface $input, OutputInterface $output) |
||
182 | } |
||
183 |