SchemaCreateTableColumnEventArgs.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 func_get_args;
  8. use function is_array;
  9. /**
  10. * Event Arguments used when SQL queries for creating table columns are generated inside {@link AbstractPlatform}.
  11. */
  12. class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
  13. {
  14. /** @var Column */
  15. private $column;
  16. /** @var Table */
  17. private $table;
  18. /** @var AbstractPlatform */
  19. private $platform;
  20. /** @var string[] */
  21. private $sql = [];
  22. public function __construct(Column $column, Table $table, AbstractPlatform $platform)
  23. {
  24. $this->column = $column;
  25. $this->table = $table;
  26. $this->platform = $platform;
  27. }
  28. /**
  29. * @return Column
  30. */
  31. public function getColumn()
  32. {
  33. return $this->column;
  34. }
  35. /**
  36. * @return Table
  37. */
  38. public function getTable()
  39. {
  40. return $this->table;
  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 SchemaCreateTableColumnEventArgs
  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. }