Skip to content

Instantly share code, notes, and snippets.

Last active June 29, 2022 10:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Sulu CMS Import articles from an existing CMS
// src/Commands/ImportExternalCmsCommand.php
namespace App\Commands;
use Doctrine\ORM\EntityManagerInterface;
use Sulu\Component\DocumentManager\DocumentManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ImportExternalCmsCommand extends Command
protected static $defaultName = 'sulu:import-external-cms';
protected static $defaultDescription = 'Import all articles from an external CMS via DBAL and create Sulu articles with the document manager.';
private $entityManager;
private $documentManager;
public function __construct(EntityManagerInterface $entityManager, DocumentManagerInterface $documentManager)
$this->entityManager = $entityManager;
$this->documentManager = $documentManager;
protected function execute(InputInterface $input, OutputInterface $output): int
// TODO:
// - query old articles via entity manager
// - return Generator with articles data
// - save articles via document manager
return 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment