SchemaColumnDefinitionEventArgs.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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\Column;
  22. /**
  23. * Event Arguments used when the portable column 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 SchemaColumnDefinitionEventArgs extends SchemaEventArgs
  30. {
  31. /**
  32. * @var \Doctrine\DBAL\Schema\Column|null
  33. */
  34. private $_column = null;
  35. /**
  36. * Raw column data as fetched from the database.
  37. *
  38. * @var array
  39. */
  40. private $_tableColumn;
  41. /**
  42. * @var string
  43. */
  44. private $_table;
  45. /**
  46. * @var string
  47. */
  48. private $_database;
  49. /**
  50. * @var \Doctrine\DBAL\Connection
  51. */
  52. private $_connection;
  53. /**
  54. * @param array $tableColumn
  55. * @param string $table
  56. * @param string $database
  57. * @param \Doctrine\DBAL\Connection $connection
  58. */
  59. public function __construct(array $tableColumn, $table, $database, Connection $connection)
  60. {
  61. $this->_tableColumn = $tableColumn;
  62. $this->_table = $table;
  63. $this->_database = $database;
  64. $this->_connection = $connection;
  65. }
  66. /**
  67. * Allows to clear the column which means the column will be excluded from
  68. * tables column list.
  69. *
  70. * @param null|\Doctrine\DBAL\Schema\Column $column
  71. *
  72. * @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs
  73. */
  74. public function setColumn(Column $column = null)
  75. {
  76. $this->_column = $column;
  77. return $this;
  78. }
  79. /**
  80. * @return \Doctrine\DBAL\Schema\Column|null
  81. */
  82. public function getColumn()
  83. {
  84. return $this->_column;
  85. }
  86. /**
  87. * @return array
  88. */
  89. public function getTableColumn()
  90. {
  91. return $this->_tableColumn;
  92. }
  93. /**
  94. * @return string
  95. */
  96. public function getTable()
  97. {
  98. return $this->_table;
  99. }
  100. /**
  101. * @return string
  102. */
  103. public function getDatabase()
  104. {
  105. return $this->_database;
  106. }
  107. /**
  108. * @return \Doctrine\DBAL\Connection
  109. */
  110. public function getConnection()
  111. {
  112. return $this->_connection;
  113. }
  114. /**
  115. * @return \Doctrine\DBAL\Platforms\AbstractPlatform
  116. */
  117. public function getDatabasePlatform()
  118. {
  119. return $this->_connection->getDatabasePlatform();
  120. }
  121. }