1<?php 2 3namespace Doctrine\DBAL\Event; 4 5use Doctrine\DBAL\Platforms\AbstractPlatform; 6use Doctrine\DBAL\Schema\Table; 7 8use function array_merge; 9use function func_get_args; 10use function is_array; 11 12/** 13 * Event Arguments used when SQL queries for creating tables are generated inside {@link AbstractPlatform}. 14 */ 15class SchemaCreateTableEventArgs extends SchemaEventArgs 16{ 17 /** @var Table */ 18 private $table; 19 20 /** @var mixed[][] */ 21 private $columns; 22 23 /** @var mixed[] */ 24 private $options; 25 26 /** @var AbstractPlatform */ 27 private $platform; 28 29 /** @var string[] */ 30 private $sql = []; 31 32 /** 33 * @param mixed[][] $columns 34 * @param mixed[] $options 35 */ 36 public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform) 37 { 38 $this->table = $table; 39 $this->columns = $columns; 40 $this->options = $options; 41 $this->platform = $platform; 42 } 43 44 /** 45 * @return Table 46 */ 47 public function getTable() 48 { 49 return $this->table; 50 } 51 52 /** 53 * @return mixed[][] 54 */ 55 public function getColumns() 56 { 57 return $this->columns; 58 } 59 60 /** 61 * @return mixed[] 62 */ 63 public function getOptions() 64 { 65 return $this->options; 66 } 67 68 /** 69 * @return AbstractPlatform 70 */ 71 public function getPlatform() 72 { 73 return $this->platform; 74 } 75 76 /** 77 * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead. 78 * 79 * @param string|string[] $sql 80 * 81 * @return SchemaCreateTableEventArgs 82 */ 83 public function addSql($sql) 84 { 85 $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args()); 86 87 return $this; 88 } 89 90 /** 91 * @return string[] 92 */ 93 public function getSql() 94 { 95 return $this->sql; 96 } 97} 98