Jarves\Command\ContentImportCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $basePath = 'app/jarves/';
        $fs = new Filesystem();
        if (!$fs->exists($basePath)) {
            $output->writeln(sprintf('<error>No website data in %s</error>', $basePath));
            return;
        }
        $files = $this->import($input, $output);
        if (!$input->getOption('watch')) {
            $output->writeln("<info>Done.</info>");
        } else {
            do {
                $output->writeln("<info>Done. Wait for changes ...</info>");
                while (true) {
                    sleep(1);
                    clearstatcache();
                    foreach ($files as $path => $mtime) {
                        if ($mtime !== filemtime($path)) {
                            $output->writeln(sprintf("<info>%s changed. Reimport</info>", $path));
                            break 2;
                        }
                    }
                }
                try {
                    $files = $this->import($input, $output);
                } catch (\Exception $e) {
                    foreach ($files as $path => $mtime) {
                        $files[$path] = filemtime($path);
                    }
                    $output->writeln("<error>Failed</error>");
                    echo Debug::toString($e);
                    $output->writeln("<info>Waiting for changes ...</info>");
                }
            } while (true);
        }
    }