filesystem = $filesystem; } /** * {@inheritdoc} */ protected function configure() { $this->setName(self::COMMAND_NAME) ->setDescription('Enable the profiler.') ->addArgument('type', InputArgument::OPTIONAL, 'Profiler type'); parent::configure(); } /** * {@inheritdoc} * @throws \InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) { $type = $input->getArgument('type'); if (!$type) { $type = self::TYPE_DEFAULT; } if (!in_array($type, self::BUILT_IN_TYPES, true)) { $builtInTypes = implode(', ', self::BUILT_IN_TYPES); $output->writeln( '' . sprintf('Type %s is not one of the built-in output types (%s).', $type, $builtInTypes) . '' ); } $this->filesystem->write(BP . '/' . self::PROFILER_FLAG_FILE, $type); if ($this->filesystem->fileExists(BP . '/' . self::PROFILER_FLAG_FILE)) { $output->write(''. sprintf(self::SUCCESS_MESSAGE, $type) . ''); if ($type == 'csvfile') { $output->write( ' ' . sprintf( 'Output will be saved in %s', \Magento\Framework\Profiler\Driver\Standard\Output\Csvfile::DEFAULT_FILEPATH ) . '' ); } $output->write(PHP_EOL); return; } $output->writeln('Something went wrong while enabling the profiler.'); } }