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