SchemaAlterTableRenameColumnEventArgs.php 2.0 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 func_get_args;
  8. use function is_array;
  9. /**
  10. * Event Arguments used when SQL queries for renaming table columns are generated inside {@link AbstractPlatform}.
  11. */
  12. class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
  13. {
  14. /** @var string */
  15. private $oldColumnName;
  16. /** @var Column */
  17. private $column;
  18. /** @var TableDiff */
  19. private $tableDiff;
  20. /** @var AbstractPlatform */
  21. private $platform;
  22. /** @var string[] */
  23. private $sql = [];
  24. /**
  25. * @param string $oldColumnName
  26. */
  27. public function __construct($oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
  28. {
  29. $this->oldColumnName = $oldColumnName;
  30. $this->column = $column;
  31. $this->tableDiff = $tableDiff;
  32. $this->platform = $platform;
  33. }
  34. /**
  35. * @return string
  36. */
  37. public function getOldColumnName()
  38. {
  39. return $this->oldColumnName;
  40. }
  41. /**
  42. * @return Column
  43. */
  44. public function getColumn()
  45. {
  46. return $this->column;
  47. }
  48. /**
  49. * @return TableDiff
  50. */
  51. public function getTableDiff()
  52. {
  53. return $this->tableDiff;
  54. }
  55. /**
  56. * @return AbstractPlatform
  57. */
  58. public function getPlatform()
  59. {
  60. return $this->platform;
  61. }
  62. /**
  63. * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
  64. *
  65. * @param string|string[] $sql
  66. *
  67. * @return SchemaAlterTableRenameColumnEventArgs
  68. */
  69. public function addSql($sql)
  70. {
  71. $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
  72. return $this;
  73. }
  74. /**
  75. * @return string[]
  76. */
  77. public function getSql()
  78. {
  79. return $this->sql;
  80. }
  81. }