SchemaColumnDefinitionEventArgs.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Connection;
  4. use Doctrine\DBAL\Platforms\AbstractPlatform;
  5. use Doctrine\DBAL\Schema\Column;
  6. use Doctrine\Deprecations\Deprecation;
  7. /**
  8. * Event Arguments used when the portable column definition is generated inside {@link AbstractPlatform}.
  9. */
  10. class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
  11. {
  12. /** @var Column|null */
  13. private $column;
  14. /**
  15. * Raw column data as fetched from the database.
  16. *
  17. * @var mixed[]
  18. */
  19. private $tableColumn;
  20. /** @var string */
  21. private $table;
  22. /** @var string */
  23. private $database;
  24. /** @var Connection */
  25. private $connection;
  26. /**
  27. * @param mixed[] $tableColumn
  28. * @param string $table
  29. * @param string $database
  30. */
  31. public function __construct(array $tableColumn, $table, $database, Connection $connection)
  32. {
  33. $this->tableColumn = $tableColumn;
  34. $this->table = $table;
  35. $this->database = $database;
  36. $this->connection = $connection;
  37. }
  38. /**
  39. * Allows to clear the column which means the column will be excluded from
  40. * tables column list.
  41. *
  42. * @return SchemaColumnDefinitionEventArgs
  43. */
  44. public function setColumn(?Column $column = null)
  45. {
  46. $this->column = $column;
  47. return $this;
  48. }
  49. /**
  50. * @return Column|null
  51. */
  52. public function getColumn()
  53. {
  54. return $this->column;
  55. }
  56. /**
  57. * @return mixed[]
  58. */
  59. public function getTableColumn()
  60. {
  61. return $this->tableColumn;
  62. }
  63. /**
  64. * @return string
  65. */
  66. public function getTable()
  67. {
  68. return $this->table;
  69. }
  70. /**
  71. * @return string
  72. */
  73. public function getDatabase()
  74. {
  75. return $this->database;
  76. }
  77. /**
  78. * @return Connection
  79. */
  80. public function getConnection()
  81. {
  82. return $this->connection;
  83. }
  84. /**
  85. * @deprecated Use SchemaColumnDefinitionEventArgs::getConnection() and Connection::getDatabasePlatform() instead.
  86. *
  87. * @return AbstractPlatform
  88. */
  89. public function getDatabasePlatform()
  90. {
  91. Deprecation::trigger(
  92. 'doctrine/dbal',
  93. 'https://github.com/doctrine/dbal/issues/3580',
  94. 'SchemaColumnDefinitionEventArgs::getDatabasePlatform() is deprecated, ' .
  95. 'use SchemaColumnDefinitionEventArgs::getConnection()->getDatabasePlatform() instead.'
  96. );
  97. return $this->connection->getDatabasePlatform();
  98. }
  99. }