MigrationData.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Module\Setup;
  7. /**
  8. * Replace patterns needed for migration process between Magento versions
  9. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  10. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  11. */
  12. class MigrationData
  13. {
  14. /**
  15. * List of required params
  16. *
  17. * @var string[]
  18. */
  19. protected $_requiredParams = ['plain', 'wiki', 'xml', 'serialized'];
  20. /**
  21. * List of replace patterns
  22. *
  23. * @var string[]
  24. */
  25. protected $_patterns = [];
  26. /**
  27. * @param array $data
  28. * @throws \InvalidArgumentException
  29. */
  30. public function __construct(
  31. array $data
  32. ) {
  33. foreach ($this->_requiredParams as $param) {
  34. if (!isset($data[$param])) {
  35. throw new \InvalidArgumentException("Missing required param " . $param);
  36. }
  37. $this->_patterns[$param] = $data[$param];
  38. }
  39. }
  40. /**
  41. * Get replace pattern
  42. *
  43. * @return string
  44. */
  45. public function getPlainFindPattern()
  46. {
  47. return $this->_patterns['plain'];
  48. }
  49. /**
  50. * Get replace pattern
  51. *
  52. * @return string
  53. */
  54. public function getWikiFindPattern()
  55. {
  56. return $this->_patterns['wiki'];
  57. }
  58. /**
  59. * Get replace pattern
  60. *
  61. * @return string
  62. */
  63. public function getXmlFindPattern()
  64. {
  65. return $this->_patterns['xml'];
  66. }
  67. /**
  68. * Get replace pattern
  69. *
  70. * @return string
  71. */
  72. public function getSerializedFindPattern()
  73. {
  74. return $this->_patterns['serialized'];
  75. }
  76. }