1 | <?php |
||
17 | class GzJsonImportCommand extends ImportCommandBase { |
||
18 | |||
19 | 4 | protected function configure() { |
|
43 | |||
44 | 4 | protected function executeCommand( InputInterface $input, OutputInterface $output ) { |
|
45 | 4 | $dumpReader = ( new JsonDumpFactory() )->newGzDumpReader( |
|
46 | 4 | $input->getArgument( 'file' ), |
|
47 | 4 | is_numeric( $input->getOption( 'continue' ) ) ? (int)$input->getOption( 'continue' ) : 0 |
|
48 | ); |
||
49 | |||
50 | 4 | $importer = new PagesImporterCli( |
|
51 | 4 | $input, |
|
52 | 4 | $output, |
|
53 | 4 | $this->factory, |
|
|
|||
54 | 4 | function() use ( $output, $dumpReader ) { |
|
55 | $output->writeln( "\n" ); |
||
56 | $output->writeln( "<info>Import process aborted</info>" ); |
||
57 | $output->writeln( "<comment>To resume, run with</comment> --continue=" . $dumpReader->getPosition() ); |
||
58 | 4 | } |
|
59 | ); |
||
60 | |||
61 | 4 | $iterator = $this->factory->newJsonEntityPageIterator( $dumpReader ); |
|
62 | |||
63 | 4 | if ( is_numeric( $input->getOption( 'max' ) ) ) { |
|
64 | 2 | $iterator = new \LimitIterator( $iterator, 0, (int)$input->getOption( 'max' ) ); |
|
65 | } |
||
66 | |||
67 | 4 | $importer->runImport( $iterator ); |
|
68 | |||
69 | 4 | $this->outputMaxContinuation( $input, $output, $dumpReader ); |
|
70 | 4 | } |
|
71 | |||
72 | 4 | private function outputMaxContinuation( InputInterface $input, OutputInterface $output, SeekableDumpReader $reader ) { |
|
79 | |||
80 | } |
||
81 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: