SchemaIndexDefinitionEventArgs.php 1.51 KB
Newer Older
1 2
<?php

Michael Moravec's avatar
Michael Moravec committed
3 4
declare(strict_types=1);

5 6
namespace Doctrine\DBAL\Event;

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

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

    /**
Benjamin Morel's avatar
Benjamin Morel committed
19
     * Raw index data as fetched from the database.
20
     *
21
     * @var array<string, mixed>
22
     */
23
    private $tableIndex;
24

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

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

    /**
32
     * @param array<string, mixed> $tableIndex
33
     */
34
    public function __construct(array $tableIndex, string $table, Connection $connection)
35
    {
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
     * @return $this
45
     */
46
    public function setIndex(?Index $index) : self
47
    {
48
        $this->index = $index;
49 50 51 52

        return $this;
    }

53
    public function getIndex() : ?Index
54
    {
55
        return $this->index;
56 57 58
    }

    /**
59
     * @return array<string, mixed>
60
     */
61
    public function getTableIndex() : array
62
    {
63
        return $this->tableIndex;
64 65
    }

66
    public function getTable() : string
67
    {
68
        return $this->table;
69 70
    }

71
    public function getConnection() : Connection
72
    {
73
        return $this->connection;
74 75
    }
}