SchemaIndexDefinitionEventArgs.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\DBAL\Event;
  20. use Doctrine\DBAL\Connection;
  21. use Doctrine\DBAL\Schema\Index;
  22. /**
  23. * Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
  24. *
  25. * @link www.doctrine-project.org
  26. * @since 2.2
  27. * @author Jan Sorgalla <jsorgalla@googlemail.com>
  28. */
  29. class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
  30. {
  31. /**
  32. * @var \Doctrine\DBAL\Schema\Index|null
  33. */
  34. private $_index = null;
  35. /**
  36. * Raw index data as fetched from the database.
  37. *
  38. * @var array
  39. */
  40. private $_tableIndex;
  41. /**
  42. * @var string
  43. */
  44. private $_table;
  45. /**
  46. * @var \Doctrine\DBAL\Connection
  47. */
  48. private $_connection;
  49. /**
  50. * @param array $tableIndex
  51. * @param string $table
  52. * @param \Doctrine\DBAL\Connection $connection
  53. */
  54. public function __construct(array $tableIndex, $table, Connection $connection)
  55. {
  56. $this->_tableIndex = $tableIndex;
  57. $this->_table = $table;
  58. $this->_connection = $connection;
  59. }
  60. /**
  61. * Allows to clear the index which means the index will be excluded from tables index list.
  62. *
  63. * @param null|\Doctrine\DBAL\Schema\Index $index
  64. *
  65. * @return SchemaIndexDefinitionEventArgs
  66. */
  67. public function setIndex(Index $index = null)
  68. {
  69. $this->_index = $index;
  70. return $this;
  71. }
  72. /**
  73. * @return \Doctrine\DBAL\Schema\Index|null
  74. */
  75. public function getIndex()
  76. {
  77. return $this->_index;
  78. }
  79. /**
  80. * @return array
  81. */
  82. public function getTableIndex()
  83. {
  84. return $this->_tableIndex;
  85. }
  86. /**
  87. * @return string
  88. */
  89. public function getTable()
  90. {
  91. return $this->_table;
  92. }
  93. /**
  94. * @return \Doctrine\DBAL\Connection
  95. */
  96. public function getConnection()
  97. {
  98. return $this->_connection;
  99. }
  100. /**
  101. * @return \Doctrine\DBAL\Platforms\AbstractPlatform
  102. */
  103. public function getDatabasePlatform()
  104. {
  105. return $this->_connection->getDatabasePlatform();
  106. }
  107. }