SchemaAlterTableEventArgs.php 2.6 KB

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