setName('generate:doc:data') ->setDescription( $this->trans('commands.generate.doc.data.description') ) ->addOption( 'file', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.doc.data.options.file') ); ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $file = null; if ($input->hasOption('file')) { $file = $input->getOption('file'); } $data = $this->getApplication()->getData(); if ($file) { file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT)); return 0; } $io->write(json_encode($data, JSON_PRETTY_PRINT)); } }