1 | <?php declare (strict_types = 1); |
||
39 | trait SeedTrait |
||
40 | { |
||
41 | /** |
||
42 | * @var ContainerInterface |
||
43 | */ |
||
44 | private $container; |
||
45 | |||
46 | /** |
||
47 | * @inheritdoc |
||
48 | */ |
||
49 | 1 | public function init(ContainerInterface $container): SeedInterface |
|
58 | |||
59 | /** |
||
60 | * @return ContainerInterface |
||
61 | */ |
||
62 | 1 | protected function getContainer(): ContainerInterface |
|
66 | |||
67 | /** |
||
68 | * @return Connection |
||
69 | */ |
||
70 | 1 | protected function getConnection(): Connection |
|
76 | |||
77 | /** |
||
78 | * @return ModelSchemaInfoInterface |
||
79 | */ |
||
80 | 1 | protected function getModelSchemas(): ModelSchemaInfoInterface |
|
86 | |||
87 | /** |
||
88 | * @return AbstractSchemaManager |
||
89 | */ |
||
90 | 1 | protected function getSchemaManager(): AbstractSchemaManager |
|
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | * |
||
98 | * @throws Exception |
||
99 | */ |
||
100 | 1 | protected function now(): string |
|
107 | |||
108 | /** |
||
109 | * @param string $tableName |
||
110 | * @param null|int $limit |
||
111 | * |
||
112 | * @return array |
||
113 | */ |
||
114 | 1 | protected function readTableData(string $tableName, int $limit = null): array |
|
129 | |||
130 | /** |
||
131 | * @param string $modelClass |
||
132 | * @param null|int $limit |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 1 | protected function readModelsData(string $modelClass, int $limit = null): array |
|
140 | |||
141 | /** |
||
142 | * @param int $records |
||
143 | * @param string $tableName |
||
144 | * @param Closure $dataClosure |
||
145 | * @param array $columnTypes |
||
146 | * |
||
147 | * @return void |
||
148 | * |
||
149 | * @throws DBALException |
||
150 | */ |
||
151 | 1 | protected function seedTableData(int $records, $tableName, Closure $dataClosure, array $columnTypes = []): void |
|
160 | |||
161 | /** |
||
162 | * @param int $records |
||
163 | * @param string $modelClass |
||
164 | * @param Closure $dataClosure |
||
165 | * |
||
166 | * @return void |
||
167 | * |
||
168 | * @throws DBALException |
||
169 | */ |
||
170 | 1 | protected function seedModelsData(int $records, string $modelClass, Closure $dataClosure): void |
|
176 | |||
177 | /** |
||
178 | * @param string $tableName |
||
179 | * @param array $data |
||
180 | * @param array $columnTypes |
||
181 | * |
||
182 | * @return void |
||
183 | * |
||
184 | * @throws DBALException |
||
185 | */ |
||
186 | 1 | protected function seedRowData(string $tableName, array $data, array $columnTypes = []): void |
|
192 | |||
193 | /** |
||
194 | * @param string $modelClass |
||
195 | * @param array $data |
||
196 | * |
||
197 | * @return void |
||
198 | * |
||
199 | * @throws DBALException |
||
200 | */ |
||
201 | 1 | protected function seedModelData(string $modelClass, array $data): void |
|
207 | |||
208 | /** |
||
209 | * @return string |
||
210 | */ |
||
211 | 1 | protected function getLastInsertId(): string |
|
215 | |||
216 | /** |
||
217 | * @param string $tableName |
||
218 | * @param Connection $connection |
||
219 | * @param array $data |
||
220 | * @param Closure $getColumnType |
||
221 | * |
||
222 | * @return void |
||
223 | * |
||
224 | * @throws DBALException |
||
225 | */ |
||
226 | 1 | private function insertRow($tableName, Connection $connection, array $data, Closure $getColumnType): void |
|
243 | |||
244 | /** |
||
245 | * @param array $attributeTypes |
||
246 | * |
||
247 | * @return Closure |
||
248 | */ |
||
249 | 1 | private function createAttributeTypeGetter(array $attributeTypes): Closure |
|
256 | } |
||
257 |