MySQLSearchDeprecationNotification.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\CatalogSearch\Setup\Patch\Data;
  8. /**
  9. * Implementation of the notification about MySQL search being deprecated.
  10. *
  11. * @deprecated 101.0.0
  12. * @see \Magento\ElasticSearch
  13. */
  14. class MySQLSearchDeprecationNotification implements \Magento\Framework\Setup\Patch\DataPatchInterface
  15. {
  16. /**
  17. * @var \Magento\Framework\Search\EngineResolverInterface
  18. */
  19. private $searchEngineResolver;
  20. /**
  21. * @var \Magento\Framework\Notification\NotifierInterface
  22. */
  23. private $notifier;
  24. /**
  25. * @param \Magento\Framework\Search\EngineResolverInterface $searchEngineResolver
  26. * @param \Magento\Framework\Notification\NotifierInterface $notifier
  27. */
  28. public function __construct(
  29. \Magento\Framework\Search\EngineResolverInterface $searchEngineResolver,
  30. \Magento\Framework\Notification\NotifierInterface $notifier
  31. ) {
  32. $this->searchEngineResolver = $searchEngineResolver;
  33. $this->notifier = $notifier;
  34. }
  35. /**
  36. * @inheritdoc
  37. */
  38. public function apply()
  39. {
  40. if ($this->searchEngineResolver->getCurrentSearchEngine() === 'mysql') {
  41. $message = <<<MESSAGE
  42. Catalog Search is currently configured to use the MySQL engine, which has been deprecated. Consider migrating to one of
  43. the Elasticsearch engines now to ensure there are no service interruptions during your next upgrade.
  44. MESSAGE;
  45. $this->notifier->addNotice(__('Deprecation Notice'), __($message));
  46. }
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function getAliases()
  52. {
  53. return [];
  54. }
  55. /**
  56. * @inheritdoc
  57. */
  58. public static function getDependencies()
  59. {
  60. return [];
  61. }
  62. }