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