SchemaAlterTableEventArgs.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Platforms\AbstractPlatform;
  4. use Doctrine\DBAL\Schema\TableDiff;
  5. use function array_merge;
  6. use function is_array;
  7. /**
  8. * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform.
  9. */
  10. class SchemaAlterTableEventArgs extends SchemaEventArgs
  11. {
  12. /** @var TableDiff */
  13. private $tableDiff;
  14. /** @var AbstractPlatform */
  15. private $platform;
  16. /** @var string[] */
  17. private $sql = [];
  18. public function __construct(TableDiff $tableDiff, AbstractPlatform $platform)
  19. {
  20. $this->tableDiff = $tableDiff;
  21. $this->platform = $platform;
  22. }
  23. /**
  24. * @return TableDiff
  25. */
  26. public function getTableDiff()
  27. {
  28. return $this->tableDiff;
  29. }
  30. /**
  31. * @return AbstractPlatform
  32. */
  33. public function getPlatform()
  34. {
  35. return $this->platform;
  36. }
  37. /**
  38. * @param string|string[] $sql
  39. *
  40. * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
  41. */
  42. public function addSql($sql)
  43. {
  44. if (is_array($sql)) {
  45. $this->sql = array_merge($this->sql, $sql);
  46. } else {
  47. $this->sql[] = $sql;
  48. }
  49. return $this;
  50. }
  51. /**
  52. * @return string[]
  53. */
  54. public function getSql()
  55. {
  56. return $this->sql;
  57. }
  58. }