SchemaDropTableEventArgs.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\DBAL\Platforms\AbstractPlatform;
  4. use Doctrine\DBAL\Schema\Table;
  5. use InvalidArgumentException;
  6. use function is_string;
  7. /**
  8. * Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
  9. */
  10. class SchemaDropTableEventArgs extends SchemaEventArgs
  11. {
  12. /** @var string|Table */
  13. private $table;
  14. /** @var AbstractPlatform */
  15. private $platform;
  16. /** @var string|null */
  17. private $sql = null;
  18. /**
  19. * @param string|Table $table
  20. *
  21. * @throws InvalidArgumentException
  22. */
  23. public function __construct($table, AbstractPlatform $platform)
  24. {
  25. if (! $table instanceof Table && ! is_string($table)) {
  26. throw new InvalidArgumentException('SchemaDropTableEventArgs expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
  27. }
  28. $this->table = $table;
  29. $this->platform = $platform;
  30. }
  31. /**
  32. * @return string|Table
  33. */
  34. public function getTable()
  35. {
  36. return $this->table;
  37. }
  38. /**
  39. * @return AbstractPlatform
  40. */
  41. public function getPlatform()
  42. {
  43. return $this->platform;
  44. }
  45. /**
  46. * @param string $sql
  47. *
  48. * @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs
  49. */
  50. public function setSql($sql)
  51. {
  52. $this->sql = $sql;
  53. return $this;
  54. }
  55. /**
  56. * @return string|null
  57. */
  58. public function getSql()
  59. {
  60. return $this->sql;
  61. }
  62. }