public function execute(InputInterface $input, OutputInterface $output)
    {
        $assetsDirectory = str_replace('/', DIRECTORY_SEPARATOR, 'web/bundles');

        $manager = $this->getDocumentManager();
        $assetFactory = $this->getAssetFactory();

        if ($input->getOption('clear')) {
            $output->writeln('Clearing assets from the content repository. This should NEVER be used in a production environment unless you know what you\'re doing!');

            if ($assetNode = $manager->find(null, '/asset')) {
                $manager->remove($assetNode);
                $manager->flush();
                $manager->clear();
            }
        }

        $batchSize = (int) $input->getOption('batchSize') ?: self::$defaultBatchSize;
        $assetFileArray = $this->getAssetFileArray($assetsDirectory);
        if (count($assetFileArray) === 0) {
            $output->writeln('No assets to move, please run the assets:install command first.');
            return 1; // failure
        }

        $output->writeln('Moving assets into content repository...');
        $progress = new ProgressBar($output, count($assetFileArray));
        $progress->setFormat('verbose');
        $progress->start();

        foreach (array_chunk($assetFileArray, $batchSize) as $chunk) {
            foreach ($chunk as $fileArr) {
                /** @var \SplFileInfo $file */
                $file = $fileArr['file'];
                $linkedLocation = $fileArr['linkedLocation'];

                $parentPath = $file->getPath();
                if ($linkedLocation) {
                    $needle = DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR;
                    $pos = strpos($parentPath, $needle);
                    $parentPath = $linkedLocation . DIRECTORY_SEPARATOR . substr($parentPath, $pos + strlen($needle));
                }
                $parentPath = str_replace($assetsDirectory . DIRECTORY_SEPARATOR, '', $parentPath);
                $parentPath = str_replace('\\', '/', $parentPath);
                $parentNode = $this->findOrCreateNode('asset/' . $parentPath);

                /** @var FileDocument|ImageDocument $asset */
                $asset = $assetFactory->create($file);
                $asset
                    ->copyContentFromFile($file)
                    ->setParentDocument($parentNode)
                    ->setNodename($file->getBasename())
                ;

                $manager->persist($asset);
                $progress->advance();
            }

            $manager->flush();
            $manager->clear();
        }

        $this->deleteDirectoryContents($assetsDirectory);
        $progress->finish();
        $output->writeln("\nFinished!");

        return 0; // everything went okay
    }