SchemaAlterTableChangeColumnEventArgs.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Platforms\AbstractPlatform;
  4. use Doctrine\DBAL\Schema\ColumnDiff;
  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 changing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
  10. */
  11. class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
  12. {
  13. /** @var ColumnDiff */
  14. private $columnDiff;
  15. /** @var TableDiff */
  16. private $tableDiff;
  17. /** @var AbstractPlatform */
  18. private $platform;
  19. /** @var string[] */
  20. private $sql = [];
  21. public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
  22. {
  23. $this->columnDiff = $columnDiff;
  24. $this->tableDiff = $tableDiff;
  25. $this->platform = $platform;
  26. }
  27. /**
  28. * @return ColumnDiff
  29. */
  30. public function getColumnDiff()
  31. {
  32. return $this->columnDiff;
  33. }
  34. /**
  35. * @return TableDiff
  36. */
  37. public function getTableDiff()
  38. {
  39. return $this->tableDiff;
  40. }
  41. /**
  42. * @return AbstractPlatform
  43. */
  44. public function getPlatform()
  45. {
  46. return $this->platform;
  47. }
  48. /**
  49. * @param string|string[] $sql
  50. *
  51. * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
  52. */
  53. public function addSql($sql)
  54. {
  55. if (is_array($sql)) {
  56. $this->sql = array_merge($this->sql, $sql);
  57. } else {
  58. $this->sql[] = $sql;
  59. }
  60. return $this;
  61. }
  62. /**
  63. * @return string[]
  64. */
  65. public function getSql()
  66. {
  67. return $this->sql;
  68. }
  69. }