entityManager = $entityManager; $this->entryRepository = $entryRepository; $this->wallabagUrl = $wallabagUrl; parent::__construct(); } protected function configure() { $this ->addArgument( 'old-url', InputArgument::REQUIRED, 'URL to replace' ); } protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $oldUrl = $input->getArgument('old-url'); $query = $this->entryRepository->createQueryBuilder('e')->getQuery(); $io->text('Retrieve existing entries'); $i = 1; foreach ($query->toIterable() as $entry) { $content = $entry->getContent(); if (null !== $content) { $entry->setContent(str_replace($oldUrl, $this->wallabagUrl, $content)); } $previewPicture = $entry->getPreviewPicture(); if (null !== $previewPicture) { $entry->setPreviewPicture(str_replace($oldUrl, $this->wallabagUrl, $previewPicture)); } if (0 === ($i % 20)) { $this->entityManager->flush(); } ++$i; } $this->entityManager->flush(); $io->success('Finished updating.'); return 0; } }