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