SchemaAlterTableEventArgs.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 LGPL. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\DBAL\Event;
  20. use Doctrine\DBAL\Platforms\AbstractPlatform,
  21. Doctrine\DBAL\Schema\Column,
  22. Doctrine\DBAL\Schema\TableDiff;
  23. /**
  24. * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform.
  25. *
  26. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  27. * @link www.doctrine-project.com
  28. * @since 2.2
  29. * @author Jan Sorgalla <jsorgalla@googlemail.com>
  30. */
  31. class SchemaAlterTableEventArgs extends SchemaEventArgs
  32. {
  33. /**
  34. * @var \Doctrine\DBAL\Schema\TableDiff
  35. */
  36. private $_tableDiff = null;
  37. /**
  38. * @var \Doctrine\DBAL\Platforms\AbstractPlatform
  39. */
  40. private $_platform = null;
  41. /**
  42. * @var array
  43. */
  44. private $_sql = array();
  45. /**
  46. * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
  47. * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  48. */
  49. public function __construct(TableDiff $tableDiff, AbstractPlatform $platform)
  50. {
  51. $this->_tableDiff = $tableDiff;
  52. $this->_platform = $platform;
  53. }
  54. /**
  55. * @return \Doctrine\DBAL\Schema\TableDiff
  56. */
  57. public function getTableDiff()
  58. {
  59. return $this->_tableDiff;
  60. }
  61. /**
  62. * @return \Doctrine\DBAL\Platforms\AbstractPlatform
  63. */
  64. public function getPlatform()
  65. {
  66. return $this->_platform;
  67. }
  68. /**
  69. * @param string|array $sql
  70. * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
  71. */
  72. public function addSql($sql)
  73. {
  74. if (is_array($sql)) {
  75. $this->_sql = array_merge($this->_sql, $sql);
  76. } else {
  77. $this->_sql[] = $sql;
  78. }
  79. return $this;
  80. }
  81. /**
  82. * @return array
  83. */
  84. public function getSql()
  85. {
  86. return $this->_sql;
  87. }
  88. }