From c10424a62df875f5eac7c4896c0eb7a0cb379152 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Wed, 12 Jun 2019 11:49:02 +0200 Subject: [PATCH] Remove calls to deprecated method where possible --- Command/LoadDataFixturesDoctrineCommand.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Command/LoadDataFixturesDoctrineCommand.php b/Command/LoadDataFixturesDoctrineCommand.php index b62e734a..d4bea034 100644 --- a/Command/LoadDataFixturesDoctrineCommand.php +++ b/Command/LoadDataFixturesDoctrineCommand.php @@ -85,9 +85,15 @@ protected function execute(InputInterface $input, OutputInterface $output) { $ui = new SymfonyStyle($input, $output); - /** @var ManagerRegistry $doctrine */ - $doctrine = $this->getContainer()->get('doctrine'); - $em = $doctrine->getManager($input->getOption('em')); + // @todo The method_exists call can be removed once the DoctrineBundle dependency has been bumped to at least 1.10 + if (method_exists($this, 'getDotrine')) { + $doctrine = $this->getDoctrine(); + } else { + /** @var ManagerRegistry $doctrine */ + $doctrine = $this->getContainer()->get('doctrine'); + } + + $em = $doctrine->getManager($input->getOption('em')); if (! $input->getOption('append')) { if (! $ui->confirm(sprintf('Careful, database "%s" will be purged. Do you want to continue?', $em->getConnection()->getDatabase()), ! $input->isInteractive())) {