1 | <?php |
||
41 | class Field implements Buildable |
||
42 | { |
||
43 | use Macroable; |
||
44 | use Queueable { |
||
45 | build as buildQueued; |
||
46 | } |
||
47 | use QueuesMacros; |
||
48 | use GedmoFieldHints; |
||
49 | |||
50 | /** |
||
51 | * @var FieldBuilder |
||
52 | */ |
||
53 | protected $fieldBuilder; |
||
54 | |||
55 | /** |
||
56 | * @var ClassMetadataBuilder |
||
57 | */ |
||
58 | protected $metaDatabuilder; |
||
59 | |||
60 | /** |
||
61 | * @var ClassMetadataInfo |
||
62 | */ |
||
63 | protected $classMetadata; |
||
64 | |||
65 | /** |
||
66 | * @var Type |
||
67 | */ |
||
68 | protected $type; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $name; |
||
74 | |||
75 | /** |
||
76 | * Protected constructor to force usage of factory method. |
||
77 | * |
||
78 | * @param FieldBuilder $fieldBuilder |
||
79 | * @param ClassMetadataBuilder $builder |
||
80 | * @param Type $type |
||
81 | * @param string $name |
||
82 | */ |
||
83 | 301 | protected function __construct(FieldBuilder $fieldBuilder, ClassMetadataBuilder $builder, Type $type, $name) |
|
91 | |||
92 | /** |
||
93 | * @param ClassMetadataBuilder $builder |
||
94 | * @param string $type |
||
95 | * @param string $name |
||
96 | * |
||
97 | * @throws \Doctrine\DBAL\DBALException |
||
98 | * |
||
99 | * @return Field |
||
100 | */ |
||
101 | 301 | public static function make(ClassMetadataBuilder $builder, $type, $name) |
|
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 106 | public function getName() |
|
117 | |||
118 | /** |
||
119 | * @return Type |
||
120 | */ |
||
121 | 1 | public function getType() |
|
125 | |||
126 | /** |
||
127 | * @return ClassMetadata|ExtensibleClassMetadata |
||
128 | */ |
||
129 | 104 | public function getClassMetadata() |
|
133 | |||
134 | /** |
||
135 | * By default the property name is used for the database column name also, however the ‘name’ attribute |
||
136 | * allows you to determine the column name. |
||
137 | * |
||
138 | * @param string $columnName |
||
139 | * |
||
140 | * @return $this |
||
141 | */ |
||
142 | 6 | public function name($columnName) |
|
148 | |||
149 | /** |
||
150 | * @return Field |
||
151 | */ |
||
152 | 8 | public function autoIncrement() |
|
158 | |||
159 | /** |
||
160 | * @param callable|null $callback |
||
161 | * |
||
162 | * @return Field |
||
163 | */ |
||
164 | 13 | public function generatedValue(callable $callback = null) |
|
176 | |||
177 | /** |
||
178 | * Boolean value to determine if the column should be capable of representing only non-negative integers |
||
179 | * (applies only for integer column and might not be supported by all vendors). |
||
180 | * |
||
181 | * @return Field |
||
182 | */ |
||
183 | 11 | public function unsigned() |
|
189 | |||
190 | /** |
||
191 | * Boolean value to determine if the specified length of a string column should be fixed or varying |
||
192 | * (applies only for string/binary column and might not be supported by all vendors). |
||
193 | * |
||
194 | * @param bool $fixed |
||
195 | * |
||
196 | * @return Field |
||
197 | */ |
||
198 | 1 | public function fixed($fixed) |
|
204 | |||
205 | /** |
||
206 | * The comment of the column in the schema (might not be supported by all vendors). |
||
207 | * |
||
208 | * @param string $comment |
||
209 | * |
||
210 | * @return Field |
||
211 | */ |
||
212 | 1 | public function comment($comment) |
|
218 | |||
219 | /** |
||
220 | * The collation of the column (only supported by Drizzle, Mysql, PostgreSQL>=9.1, Sqlite and SQLServer). |
||
221 | * |
||
222 | * @param string $collation |
||
223 | * |
||
224 | * @return Field |
||
225 | */ |
||
226 | 1 | public function collation($collation) |
|
232 | |||
233 | /** |
||
234 | * @return Field |
||
235 | */ |
||
236 | 9 | public function primary() |
|
242 | |||
243 | /** |
||
244 | * @param string|null $name |
||
245 | * |
||
246 | * @return Field |
||
247 | */ |
||
248 | 2 | public function index($name = null) |
|
263 | |||
264 | /** |
||
265 | * @return Field |
||
266 | */ |
||
267 | 21 | public function useForVersioning() |
|
273 | |||
274 | /** |
||
275 | * @return Field |
||
276 | */ |
||
277 | 192 | public function build() |
|
285 | |||
286 | /** |
||
287 | * @return FieldBuilder |
||
288 | */ |
||
289 | 69 | public function getBuilder() |
|
293 | |||
294 | /** |
||
295 | * Magic call method works as a proxy for the Doctrine FieldBuilder. |
||
296 | * |
||
297 | * @param string $method |
||
298 | * @param array $args |
||
299 | * |
||
300 | * @throws BadMethodCallException |
||
301 | * |
||
302 | * @return $this |
||
303 | */ |
||
304 | 164 | public function __call($method, $args) |
|
323 | |||
324 | /** |
||
325 | * The default value to set for the column if no value is supplied. |
||
326 | * |
||
327 | * @param string $default |
||
328 | * |
||
329 | * @return Field |
||
330 | */ |
||
331 | 1 | protected function setDefault($default) |
|
337 | } |
||
338 |