SchemaCreateTableEventArgs.php 3.2 KB

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