SchemaAlterTableRenameColumnEventArgs.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Platforms\AbstractPlatform;
  4. use Doctrine\DBAL\Schema\Column;
  5. use Doctrine\DBAL\Schema\TableDiff;
  6. use function array_merge;
  7. use function is_array;
  8. /**
  9. * Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform.
  10. */
  11. class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
  12. {
  13. /** @var string */
  14. private $oldColumnName;
  15. /** @var Column */
  16. private $column;
  17. /** @var TableDiff */
  18. private $tableDiff;
  19. /** @var AbstractPlatform */
  20. private $platform;
  21. /** @var string[] */
  22. private $sql = [];
  23. /**
  24. * @param string $oldColumnName
  25. */
  26. public function __construct($oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
  27. {
  28. $this->oldColumnName = $oldColumnName;
  29. $this->column = $column;
  30. $this->tableDiff = $tableDiff;
  31. $this->platform = $platform;
  32. }
  33. /**
  34. * @return string
  35. */
  36. public function getOldColumnName()
  37. {
  38. return $this->oldColumnName;
  39. }
  40. /**
  41. * @return Column
  42. */
  43. public function getColumn()
  44. {
  45. return $this->column;
  46. }
  47. /**
  48. * @return TableDiff
  49. */
  50. public function getTableDiff()
  51. {
  52. return $this->tableDiff;
  53. }
  54. /**
  55. * @return AbstractPlatform
  56. */
  57. public function getPlatform()
  58. {
  59. return $this->platform;
  60. }
  61. /**
  62. * @param string|string[] $sql
  63. *
  64. * @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
  65. */
  66. public function addSql($sql)
  67. {
  68. if (is_array($sql)) {
  69. $this->sql = array_merge($this->sql, $sql);
  70. } else {
  71. $this->sql[] = $sql;
  72. }
  73. return $this;
  74. }
  75. /**
  76. * @return string[]
  77. */
  78. public function getSql()
  79. {
  80. return $this->sql;
  81. }
  82. }