SchemaIndexDefinitionEventArgs.php 1.78 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Event;

Benjamin Morel's avatar
Benjamin Morel committed
5
use Doctrine\DBAL\Connection;
6
use Doctrine\DBAL\Platforms\AbstractPlatform;
Benjamin Morel's avatar
Benjamin Morel committed
7
use Doctrine\DBAL\Schema\Index;
8 9 10 11 12 13

/**
 * Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
 */
class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
{
14
    /** @var Index|null */
15
    private $index = null;
16 17

    /**
Benjamin Morel's avatar
Benjamin Morel committed
18
     * Raw index data as fetched from the database.
19
     *
20
     * @var mixed[]
21
     */
22
    private $tableIndex;
23

24
    /** @var string */
25
    private $table;
26

27
    /** @var Connection */
28
    private $connection;
29 30

    /**
31 32
     * @param mixed[] $tableIndex
     * @param string  $table
33 34 35
     */
    public function __construct(array $tableIndex, $table, Connection $connection)
    {
36 37 38
        $this->tableIndex = $tableIndex;
        $this->table      = $table;
        $this->connection = $connection;
39 40 41
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
42
     * Allows to clear the index which means the index will be excluded from tables index list.
43 44 45
     *
     * @return SchemaIndexDefinitionEventArgs
     */
46
    public function setIndex(?Index $index = null)
47
    {
48
        $this->index = $index;
49 50 51 52 53

        return $this;
    }

    /**
54
     * @return Index|null
55 56 57
     */
    public function getIndex()
    {
58
        return $this->index;
59 60 61
    }

    /**
62
     * @return mixed[]
63 64 65
     */
    public function getTableIndex()
    {
66
        return $this->tableIndex;
67 68 69 70 71 72 73
    }

    /**
     * @return string
     */
    public function getTable()
    {
74
        return $this->table;
75 76 77
    }

    /**
78
     * @return Connection
79 80 81
     */
    public function getConnection()
    {
82
        return $this->connection;
83 84 85
    }

    /**
86
     * @return AbstractPlatform
87 88 89
     */
    public function getDatabasePlatform()
    {
90
        return $this->connection->getDatabasePlatform();
91 92
    }
}