|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Utopia\Migration\Resources\Database\Columns; |
| 4 | + |
| 5 | +use Utopia\Database\Database; |
| 6 | +use Utopia\Migration\Resources\Database\Column; |
| 7 | +use Utopia\Migration\Resources\Database\Table; |
| 8 | + |
| 9 | +class LongText extends Column |
| 10 | +{ |
| 11 | + public function __construct( |
| 12 | + string $key, |
| 13 | + Table $table, |
| 14 | + bool $required = false, |
| 15 | + ?string $default = null, |
| 16 | + bool $array = false, |
| 17 | + int $size = 2147483647, |
| 18 | + string $format = '', |
| 19 | + string $createdAt = '', |
| 20 | + string $updatedAt = '' |
| 21 | + ) { |
| 22 | + parent::__construct( |
| 23 | + $key, |
| 24 | + $table, |
| 25 | + size: $size, |
| 26 | + required: $required, |
| 27 | + default: $default, |
| 28 | + array: $array, |
| 29 | + format: $format, |
| 30 | + createdAt: $createdAt, |
| 31 | + updatedAt: $updatedAt |
| 32 | + ); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @param array{ |
| 37 | + * key: string, |
| 38 | + * collection?: array{ |
| 39 | + * database: array{ |
| 40 | + * id: string, |
| 41 | + * name: string, |
| 42 | + * }, |
| 43 | + * name: string, |
| 44 | + * id: string, |
| 45 | + * documentSecurity: bool, |
| 46 | + * permissions: ?array<string> |
| 47 | + * }, |
| 48 | + * table?: array{ |
| 49 | + * database: array{ |
| 50 | + * id: string, |
| 51 | + * name: string, |
| 52 | + * }, |
| 53 | + * name: string, |
| 54 | + * id: string, |
| 55 | + * rowSecurity: bool, |
| 56 | + * permissions: ?array<string> |
| 57 | + * }, |
| 58 | + * required: bool, |
| 59 | + * default: ?string, |
| 60 | + * array: bool, |
| 61 | + * size: int, |
| 62 | + * format: string, |
| 63 | + * createdAt: string, |
| 64 | + * updatedAt: string, |
| 65 | + * } $array |
| 66 | + * @return self |
| 67 | + */ |
| 68 | + public static function fromArray(array $array): self |
| 69 | + { |
| 70 | + return new self( |
| 71 | + $array['key'], |
| 72 | + Table::fromArray($array['table'] ?? $array['collection']), |
| 73 | + required: $array['required'], |
| 74 | + default: $array['default'] ?? null, |
| 75 | + array: $array['array'], |
| 76 | + size: $array['size'], |
| 77 | + format: $array['format'], |
| 78 | + createdAt: $array['createdAt'] ?? '', |
| 79 | + updatedAt: $array['updatedAt'] ?? '', |
| 80 | + ); |
| 81 | + } |
| 82 | + |
| 83 | + public function getType(): string |
| 84 | + { |
| 85 | + return Column::TYPE_LONGTEXT; |
| 86 | + } |
| 87 | + |
| 88 | + public function getSize(): int |
| 89 | + { |
| 90 | + return $this->size; |
| 91 | + } |
| 92 | + |
| 93 | + public function getFormat(): string |
| 94 | + { |
| 95 | + return $this->format; |
| 96 | + } |
| 97 | +} |
0 commit comments