diff --git a/Command/DoctrineODMCommand.php b/Command/DoctrineODMCommand.php
index ba40f2bf..1f3b1cd5 100644
--- a/Command/DoctrineODMCommand.php
+++ b/Command/DoctrineODMCommand.php
@@ -6,22 +6,8 @@
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;
use Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper;
-use Doctrine\Persistence\ObjectManager;
-use InvalidArgumentException;
-use LogicException;
-use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpKernel\Bundle\Bundle;
-
-use function assert;
-use function sprintf;
-use function str_replace;
-use function strtolower;
-use function trigger_deprecation;
-
-use const DIRECTORY_SEPARATOR;
/**
* Base class for Doctrine ODM console commands to extend.
@@ -30,59 +16,9 @@
*/
abstract class DoctrineODMCommand extends Command
{
- /** @var ContainerInterface|null */
- protected $container;
-
- private ?ManagerRegistry $managerRegistry;
-
- public function __construct(?ManagerRegistry $registry = null)
+ public function __construct(private ManagerRegistry $registry)
{
parent::__construct();
-
- $this->managerRegistry = $registry;
- }
-
- /** @deprecated since version 4.4 */
- public function setContainer(?ContainerInterface $container = null)
- {
- trigger_deprecation(
- 'doctrine/mongodb-odm-bundle',
- '4.4',
- 'The "%s" method is deprecated and will be dropped in DoctrineMongoDBBundle 5.0.',
- __METHOD__
- );
-
- $this->container = $container;
- }
-
- /**
- * @deprecated since version 4.4
- *
- * @return ContainerInterface
- *
- * @throws LogicException
- */
- protected function getContainer()
- {
- trigger_deprecation(
- 'doctrine/mongodb-odm-bundle',
- '4.4',
- 'The "%s" method is deprecated and will be dropped in DoctrineMongoDBBundle 5.0.',
- __METHOD__
- );
-
- if ($this->container === null) {
- $application = $this->getApplication();
- if ($application === null) {
- throw new LogicException('The container cannot be retrieved as the application instance is not yet set.');
- }
-
- assert($application instanceof Application);
-
- $this->container = $application->getKernel()->getContainer();
- }
-
- return $this->container;
}
/** @param string $dmName */
@@ -93,23 +29,6 @@ public static function setApplicationDocumentManager(Application $application, $
$helperSet->set(new DocumentManagerHelper($dm), 'dm');
}
- /**
- * @deprecated since version 4.4
- *
- * @return ObjectManager[]
- */
- protected function getDoctrineDocumentManagers()
- {
- trigger_deprecation(
- 'doctrine/mongodb-odm-bundle',
- '4.4',
- 'The "%s" method is deprecated and will be dropped in DoctrineMongoDBBundle 5.0.',
- __METHOD__
- );
-
- return $this->getManagerRegistry()->getManagers();
- }
-
/**
* @internal
*
@@ -117,78 +36,6 @@ protected function getDoctrineDocumentManagers()
*/
protected function getManagerRegistry()
{
- if ($this->managerRegistry === null) {
- $this->managerRegistry = $this->container->get('doctrine_mongodb');
- assert($this->managerRegistry instanceof ManagerRegistry);
- }
-
- return $this->managerRegistry;
- }
-
- /**
- * @deprecated since version 4.4
- *
- * @param string $bundleName
- *
- * @return Bundle
- */
- protected function findBundle($bundleName)
- {
- trigger_deprecation(
- 'doctrine/mongodb-odm-bundle',
- '4.4',
- 'The "%s" method is deprecated and will be dropped in DoctrineMongoDBBundle 5.0.',
- __METHOD__
- );
-
- $foundBundle = false;
-
- $application = $this->getApplication();
-
- assert($application instanceof Application);
-
- foreach ($application->getKernel()->getBundles() as $bundle) {
- assert($bundle instanceof Bundle);
- if (strtolower($bundleName) === strtolower($bundle->getName())) {
- $foundBundle = $bundle;
-
- break;
- }
- }
-
- if (! $foundBundle) {
- throw new InvalidArgumentException('No bundle ' . $bundleName . ' was found.');
- }
-
- return $foundBundle;
- }
-
- /**
- * Transform classname to a path $foundBundle substract it to get the destination
- *
- * @deprecated since version 4.4
- *
- * @param Bundle $bundle
- *
- * @return string
- */
- protected function findBasePathForBundle($bundle)
- {
- trigger_deprecation(
- 'doctrine/mongodb-odm-bundle',
- '4.4',
- 'The "%s" method is deprecated and will be dropped in DoctrineMongoDBBundle 5.0.',
- __METHOD__
- );
-
- $path = str_replace('\\', DIRECTORY_SEPARATOR, $bundle->getNamespace());
- $search = str_replace('\\', DIRECTORY_SEPARATOR, $bundle->getPath());
- $destination = str_replace(DIRECTORY_SEPARATOR . $path, '', $search, $c);
-
- if ($c !== 1) {
- throw new RuntimeException(sprintf('Can\'t find base path for bundle (path: "%s", destination: "%s").', $path, $destination));
- }
-
- return $destination;
+ return $this->registry;
}
}
diff --git a/Command/TailCursorDoctrineODMCommand.php b/Command/TailCursorDoctrineODMCommand.php
deleted file mode 100644
index e43fbe20..00000000
--- a/Command/TailCursorDoctrineODMCommand.php
+++ /dev/null
@@ -1,122 +0,0 @@
-setName('doctrine:mongodb:tail-cursor')
- ->setDescription('Tails a mongodb cursor and processes the documents that come through')
- ->addArgument('document', InputArgument::REQUIRED, 'The document we are going to tail the cursor for.')
- ->addArgument('finder', InputArgument::REQUIRED, 'The repository finder method which returns the cursor to tail.')
- ->addArgument('processor', InputArgument::REQUIRED, 'The service id to use to process the documents.')
- ->addOption('no-flush', null, InputOption::VALUE_NONE, 'If set, the document manager won\'t be flushed after each document processing')
- ->addOption('sleep-time', null, InputOption::VALUE_REQUIRED, 'The number of seconds to wait between two checks.', '10');
- }
-
- /** @return int */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- trigger_deprecation(
- 'doctrine/mongodb-odm-bundle',
- '4.4',
- 'The "%s" command is deprecated and will be dropped in DoctrineMongoDBBundle 5.0. You should consider using https://docs.mongodb.com/manual/changeStreams/ instead.',
- $this->getName()
- );
-
- $dm = $this->getContainer()->get('doctrine_mongodb.odm.document_manager');
- $repository = $dm->getRepository($input->getArgument('document'));
- $repositoryReflection = new ReflectionClass($repository);
- $documentReflection = $repository->getDocumentManager()->getMetadataFactory()->getMetadataFor($input->getArgument('document'))->getReflectionClass();
- $processor = $this->getContainer()->get($input->getArgument('processor'));
- $sleepTime = (int) $input->getOption('sleep-time');
-
- if (! $processor instanceof TailableCursorProcessorInterface) {
- throw new InvalidArgumentException('A tailable cursor processor must implement the ProcessorInterface.');
- }
-
- $processorReflection = new ReflectionClass($processor);
- $method = $input->getArgument('finder');
-
- $output->writeln(sprintf('Getting cursor for %s from %s#%s', $input->getArgument('document'), $repositoryReflection->getShortName(), $method));
-
- $cursor = $repository->$method();
-
- while (true) {
- while (! $cursor->hasNext()) {
- if (! $cursor->valid()) {
- $output->writeln('Invalid cursor, requerying');
- $cursor = $repository->$method();
- }
-
- $output->writeln('Nothing found, waiting to try again');
- // read all results so far, wait for more
- sleep($sleepTime);
- }
-
- $cursor->next();
- $document = $cursor->current();
- $id = $document->getId();
-
- $output->writeln(sprintf('Processing %s with id of %s', $documentReflection->getShortName(), (string) $id));
- $output->writeln(sprintf(' %s#process(%s $document)', $processorReflection->getShortName(), $documentReflection->getShortName()));
-
- try {
- $processor->process($document);
- } catch (Throwable $e) {
- $output->writeln(sprintf('Error occurred while processing document: %s', $e->getMessage()));
-
- continue;
- }
-
- if (! $input->getOption('no-flush')) {
- $dm->flush();
- }
-
- $dm->clear();
- }
-
- return 0;
- }
-
- /** @return void */
- public function setContainer(?ContainerInterface $container = null)
- {
- $this->container = $container;
- }
-
- /** @return ContainerInterface|null */
- protected function getContainer()
- {
- return $this->container;
- }
-}
diff --git a/Cursor/TailableCursorProcessorInterface.php b/Cursor/TailableCursorProcessorInterface.php
deleted file mode 100644
index e47f9584..00000000
--- a/Cursor/TailableCursorProcessorInterface.php
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 3378976c..dc12b4d3 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -40,11 +40,6 @@
protected function execute(InputInterface $input, OutputInterface $output)
-
-
- int
-
-
protected function execute(InputInterface $input, OutputInterface $output)
diff --git a/psalm.xml b/psalm.xml
index 6659793d..da0596c9 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -16,7 +16,6 @@
-