SchemaConfig.php 2.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
Benjamin Eberlei's avatar
Benjamin Eberlei committed
16
 * and is licensed under the MIT license. For more information, see
17 18 19 20 21 22
 * <http://www.doctrine-project.org>.
 */

namespace Doctrine\DBAL\Schema;

/**
Benjamin Morel's avatar
Benjamin Morel committed
23
 * Configuration for a Schema.
24
 *
Benjamin Morel's avatar
Benjamin Morel committed
25 26 27
 * @link   www.doctrine-project.org
 * @since  2.0
 * @author Benjamin Eberlei <kontakt@beberlei.de>
28 29 30 31
 */
class SchemaConfig
{
    /**
32
     * @var bool
33
     */
34
    protected $hasExplicitForeignKeyIndexes = false;
35 36

    /**
37
     * @var int
38
     */
39
    protected $maxIdentifierLength = 63;
40

41
    /**
42
     * @var string
43
     */
44 45 46 47 48
    protected $name;

    /**
     * @var array
     */
49
    protected $defaultTableOptions = [];
50

51
    /**
52
     * @return bool
53 54 55
     */
    public function hasExplicitForeignKeyIndexes()
    {
56
        return $this->hasExplicitForeignKeyIndexes;
57 58 59
    }

    /**
60
     * @param bool $flag
Benjamin Morel's avatar
Benjamin Morel committed
61 62
     *
     * @return void
63 64 65
     */
    public function setExplicitForeignKeyIndexes($flag)
    {
66
        $this->hasExplicitForeignKeyIndexes = (bool) $flag;
67 68 69
    }

    /**
70
     * @param int $length
Benjamin Morel's avatar
Benjamin Morel committed
71 72
     *
     * @return void
73 74 75
     */
    public function setMaxIdentifierLength($length)
    {
76
        $this->maxIdentifierLength = (int) $length;
77 78 79
    }

    /**
80
     * @return int
81 82 83
     */
    public function getMaxIdentifierLength()
    {
84
        return $this->maxIdentifierLength;
85
    }
86

87
    /**
Benjamin Morel's avatar
Benjamin Morel committed
88
     * Gets the default namespace of schema objects.
89 90 91 92
     *
     * @return string
     */
    public function getName()
93
    {
94
        return $this->name;
95 96
    }

97
    /**
Benjamin Morel's avatar
Benjamin Morel committed
98 99 100
     * Sets the default namespace name of schema objects.
     *
     * @param string $name The value to set.
101
     *
Benjamin Morel's avatar
Benjamin Morel committed
102
     * @return void
103 104
     */
    public function setName($name)
105
    {
106 107 108 109
        $this->name = $name;
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
110
     * Gets the default options that are passed to Table instances created with
111 112 113 114 115 116 117 118 119
     * Schema#createTable().
     *
     * @return array
     */
    public function getDefaultTableOptions()
    {
        return $this->defaultTableOptions;
    }

Benjamin Morel's avatar
Benjamin Morel committed
120 121 122 123 124
    /**
     * @param array $defaultTableOptions
     *
     * @return void
     */
125 126 127
    public function setDefaultTableOptions(array $defaultTableOptions)
    {
        $this->defaultTableOptions = $defaultTableOptions;
128 129
    }
}