SchemaAlterTableChangeColumnEventArgs.php 1.74 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Event;

Benjamin Morel's avatar
Benjamin Morel committed
5 6 7
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\TableDiff;
8
use function array_merge;
9
use function func_get_args;
10
use function is_array;
11 12 13 14

/**
 * Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
 */
jsor's avatar
jsor committed
15
class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
16
{
17
    /** @var ColumnDiff */
18
    private $columnDiff;
19

20
    /** @var TableDiff */
21
    private $tableDiff;
22

23
    /** @var AbstractPlatform */
24
    private $platform;
25

26
    /** @var string[] */
27
    private $sql = [];
28 29 30

    public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
    {
31 32 33
        $this->columnDiff = $columnDiff;
        $this->tableDiff  = $tableDiff;
        $this->platform   = $platform;
34 35 36
    }

    /**
37
     * @return ColumnDiff
38 39 40
     */
    public function getColumnDiff()
    {
41
        return $this->columnDiff;
42 43 44
    }

    /**
45
     * @return TableDiff
46 47 48
     */
    public function getTableDiff()
    {
49
        return $this->tableDiff;
50 51 52
    }

    /**
53
     * @return AbstractPlatform
54 55 56
     */
    public function getPlatform()
    {
57
        return $this->platform;
58 59 60
    }

    /**
61 62
     * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
     *
63
     * @param string|string[] $sql
Benjamin Morel's avatar
Benjamin Morel committed
64
     *
65
     * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
66 67 68
     */
    public function addSql($sql)
    {
69
        $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
70 71 72 73 74

        return $this;
    }

    /**
75
     * @return string[]
76 77 78
     */
    public function getSql()
    {
79
        return $this->sql;
80 81
    }
}