SchemaCreateTableEventArgs.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Platforms\AbstractPlatform;
  4. use Doctrine\DBAL\Schema\Table;
  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 SchemaCreateTableEventArgs extends SchemaEventArgs
  12. {
  13. /** @var Table */
  14. private $table;
  15. /** @var mixed[][] */
  16. private $columns;
  17. /** @var mixed[] */
  18. private $options;
  19. /** @var AbstractPlatform */
  20. private $platform;
  21. /** @var string[] */
  22. private $sql = [];
  23. /**
  24. * @param mixed[][] $columns
  25. * @param mixed[] $options
  26. */
  27. public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform)
  28. {
  29. $this->table = $table;
  30. $this->columns = $columns;
  31. $this->options = $options;
  32. $this->platform = $platform;
  33. }
  34. /**
  35. * @return Table
  36. */
  37. public function getTable()
  38. {
  39. return $this->table;
  40. }
  41. /**
  42. * @return mixed[][]
  43. */
  44. public function getColumns()
  45. {
  46. return $this->columns;
  47. }
  48. /**
  49. * @return mixed[]
  50. */
  51. public function getOptions()
  52. {
  53. return $this->options;
  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 SchemaCreateTableEventArgs
  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. }