SchemaIndexDefinitionEventArgs.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Connection;
  4. use Doctrine\DBAL\Platforms\AbstractPlatform;
  5. use Doctrine\DBAL\Schema\Index;
  6. /**
  7. * Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
  8. */
  9. class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
  10. {
  11. /** @var Index|null */
  12. private $index = null;
  13. /**
  14. * Raw index data as fetched from the database.
  15. *
  16. * @var mixed[]
  17. */
  18. private $tableIndex;
  19. /** @var string */
  20. private $table;
  21. /** @var Connection */
  22. private $connection;
  23. /**
  24. * @param mixed[] $tableIndex
  25. * @param string $table
  26. */
  27. public function __construct(array $tableIndex, $table, Connection $connection)
  28. {
  29. $this->tableIndex = $tableIndex;
  30. $this->table = $table;
  31. $this->connection = $connection;
  32. }
  33. /**
  34. * Allows to clear the index which means the index will be excluded from tables index list.
  35. *
  36. * @return SchemaIndexDefinitionEventArgs
  37. */
  38. public function setIndex(?Index $index = null)
  39. {
  40. $this->index = $index;
  41. return $this;
  42. }
  43. /**
  44. * @return Index|null
  45. */
  46. public function getIndex()
  47. {
  48. return $this->index;
  49. }
  50. /**
  51. * @return mixed[]
  52. */
  53. public function getTableIndex()
  54. {
  55. return $this->tableIndex;
  56. }
  57. /**
  58. * @return string
  59. */
  60. public function getTable()
  61. {
  62. return $this->table;
  63. }
  64. /**
  65. * @return Connection
  66. */
  67. public function getConnection()
  68. {
  69. return $this->connection;
  70. }
  71. /**
  72. * @return AbstractPlatform
  73. */
  74. public function getDatabasePlatform()
  75. {
  76. return $this->connection->getDatabasePlatform();
  77. }
  78. }