SchemaCreateTableEventArgs.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Platforms\AbstractPlatform;
  4. use Doctrine\DBAL\Schema\Column;
  5. use Doctrine\DBAL\Schema\Table;
  6. use function array_merge;
  7. use function is_array;
  8. /**
  9. * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
  10. */
  11. class SchemaCreateTableEventArgs extends SchemaEventArgs
  12. {
  13. /** @var Table */
  14. private $table;
  15. /** @var Column[] */
  16. private $columns;
  17. /** @var mixed[] */
  18. private $options;
  19. /** @var AbstractPlatform */
  20. private $platform;
  21. /** @var string[] */
  22. private $sql = [];
  23. /**
  24. * @param Column[] $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 Column[]
  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. * @param string|string[] $sql
  64. *
  65. * @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs
  66. */
  67. public function addSql($sql)
  68. {
  69. if (is_array($sql)) {
  70. $this->sql = array_merge($this->sql, $sql);
  71. } else {
  72. $this->sql[] = $sql;
  73. }
  74. return $this;
  75. }
  76. /**
  77. * @return string[]
  78. */
  79. public function getSql()
  80. {
  81. return $this->sql;
  82. }
  83. }