SchemaDropTableEventArgs.php 1.52 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Event;

Benjamin Morel's avatar
Benjamin Morel committed
5 6
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Table;
7
use InvalidArgumentException;
8
use function is_string;
9 10 11 12 13 14

/**
 * Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
 */
class SchemaDropTableEventArgs extends SchemaEventArgs
{
15
    /** @var string|Table */
16
    private $table;
17

18
    /** @var AbstractPlatform */
19
    private $platform;
20

21
    /** @var string|null */
22
    private $sql = null;
23 24

    /**
25
     * @param string|Table $table
Benjamin Morel's avatar
Benjamin Morel committed
26
     *
27
     * @throws InvalidArgumentException
28 29 30
     */
    public function __construct($table, AbstractPlatform $platform)
    {
31 32
        if (! $table instanceof Table && ! is_string($table)) {
            throw new InvalidArgumentException('SchemaDropTableEventArgs expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
33 34
        }

35 36
        $this->table    = $table;
        $this->platform = $platform;
37 38 39
    }

    /**
40
     * @return string|Table
41 42 43
     */
    public function getTable()
    {
44
        return $this->table;
45 46 47
    }

    /**
48
     * @return AbstractPlatform
49 50 51
     */
    public function getPlatform()
    {
52
        return $this->platform;
53 54 55 56
    }

    /**
     * @param string $sql
Benjamin Morel's avatar
Benjamin Morel committed
57
     *
58
     * @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs
59 60 61
     */
    public function setSql($sql)
    {
62
        $this->sql = $sql;
63 64 65 66 67

        return $this;
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
68
     * @return string|null
69 70 71
     */
    public function getSql()
    {
72
        return $this->sql;
73 74
    }
}