SchemaDropTableEventArgs.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 the SQL query for dropping 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 SchemaDropTableEventArgs extends SchemaEventArgs
  30. {
  31. /**
  32. * @var string|\Doctrine\DBAL\Schema\Table
  33. */
  34. private $_table;
  35. /**
  36. * @var \Doctrine\DBAL\Platforms\AbstractPlatform
  37. */
  38. private $_platform;
  39. /**
  40. * @var string|null
  41. */
  42. private $_sql = null;
  43. /**
  44. * @param string|\Doctrine\DBAL\Schema\Table $table
  45. * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  46. *
  47. * @throws \InvalidArgumentException
  48. */
  49. public function __construct($table, AbstractPlatform $platform)
  50. {
  51. if ( ! $table instanceof Table && !is_string($table)) {
  52. throw new \InvalidArgumentException('SchemaCreateTableEventArgs expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
  53. }
  54. $this->_table = $table;
  55. $this->_platform = $platform;
  56. }
  57. /**
  58. * @return string|\Doctrine\DBAL\Schema\Table
  59. */
  60. public function getTable()
  61. {
  62. return $this->_table;
  63. }
  64. /**
  65. * @return \Doctrine\DBAL\Platforms\AbstractPlatform
  66. */
  67. public function getPlatform()
  68. {
  69. return $this->_platform;
  70. }
  71. /**
  72. * @param string $sql
  73. *
  74. * @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs
  75. */
  76. public function setSql($sql)
  77. {
  78. $this->_sql = $sql;
  79. return $this;
  80. }
  81. /**
  82. * @return string|null
  83. */
  84. public function getSql()
  85. {
  86. return $this->_sql;
  87. }
  88. }