SchemaAlterTableAddColumnEventArgs.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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\Platforms\AbstractPlatform;
  21. use Doctrine\DBAL\Schema\Column;
  22. use Doctrine\DBAL\Schema\TableDiff;
  23. /**
  24. * Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform.
  25. *
  26. * @link www.doctrine-project.org
  27. * @since 2.2
  28. * @author Jan Sorgalla <jsorgalla@googlemail.com>
  29. */
  30. class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
  31. {
  32. /**
  33. * @var \Doctrine\DBAL\Schema\Column
  34. */
  35. private $_column;
  36. /**
  37. * @var \Doctrine\DBAL\Schema\TableDiff
  38. */
  39. private $_tableDiff;
  40. /**
  41. * @var \Doctrine\DBAL\Platforms\AbstractPlatform
  42. */
  43. private $_platform;
  44. /**
  45. * @var array
  46. */
  47. private $_sql = array();
  48. /**
  49. * @param \Doctrine\DBAL\Schema\Column $column
  50. * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
  51. * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  52. */
  53. public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
  54. {
  55. $this->_column = $column;
  56. $this->_tableDiff = $tableDiff;
  57. $this->_platform = $platform;
  58. }
  59. /**
  60. * @return \Doctrine\DBAL\Schema\Column
  61. */
  62. public function getColumn()
  63. {
  64. return $this->_column;
  65. }
  66. /**
  67. * @return \Doctrine\DBAL\Schema\TableDiff
  68. */
  69. public function getTableDiff()
  70. {
  71. return $this->_tableDiff;
  72. }
  73. /**
  74. * @return \Doctrine\DBAL\Platforms\AbstractPlatform
  75. */
  76. public function getPlatform()
  77. {
  78. return $this->_platform;
  79. }
  80. /**
  81. * @param string|array $sql
  82. *
  83. * @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
  84. */
  85. public function addSql($sql)
  86. {
  87. if (is_array($sql)) {
  88. $this->_sql = array_merge($this->_sql, $sql);
  89. } else {
  90. $this->_sql[] = $sql;
  91. }
  92. return $this;
  93. }
  94. /**
  95. * @return array
  96. */
  97. public function getSql()
  98. {
  99. return $this->_sql;
  100. }
  101. }