1 | <?php namespace Limoncello\Data\Seeds; |
||
35 | trait SeedTrait |
||
36 | { |
||
37 | /** |
||
38 | * @var ContainerInterface |
||
39 | */ |
||
40 | private $container; |
||
41 | |||
42 | /** |
||
43 | * @inheritdoc |
||
44 | */ |
||
45 | 1 | public function init(ContainerInterface $container): SeedInterface |
|
54 | |||
55 | /** |
||
56 | * @return ContainerInterface |
||
57 | */ |
||
58 | 1 | protected function getContainer(): ContainerInterface |
|
62 | |||
63 | /** |
||
64 | * @return Connection |
||
65 | */ |
||
66 | 1 | protected function getConnection(): Connection |
|
72 | |||
73 | /** |
||
74 | * @return ModelSchemaInfoInterface |
||
75 | */ |
||
76 | 1 | protected function getModelSchemas(): ModelSchemaInfoInterface |
|
82 | |||
83 | /** |
||
84 | * @return AbstractSchemaManager |
||
85 | */ |
||
86 | 1 | protected function getSchemaManager(): AbstractSchemaManager |
|
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | * |
||
94 | * @throws Exception |
||
95 | */ |
||
96 | 1 | protected function now(): string |
|
103 | |||
104 | /** |
||
105 | * @param string $tableName |
||
106 | * @param null|int $limit |
||
107 | * |
||
108 | * @return array |
||
109 | */ |
||
110 | 1 | protected function readTableData(string $tableName, int $limit = null): array |
|
125 | |||
126 | /** |
||
127 | * @param string $modelClass |
||
128 | * @param null|int $limit |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | 1 | protected function readModelsData(string $modelClass, int $limit = null): array |
|
136 | |||
137 | /** |
||
138 | * @param int $records |
||
139 | * @param string $tableName |
||
140 | * @param Closure $dataClosure |
||
141 | * @param array $columnTypes |
||
142 | * |
||
143 | * @return void |
||
144 | * |
||
145 | * @throws DBALException |
||
146 | */ |
||
147 | 1 | protected function seedTableData(int $records, $tableName, Closure $dataClosure, array $columnTypes = []): void |
|
156 | |||
157 | /** |
||
158 | * @param int $records |
||
159 | * @param string $modelClass |
||
160 | * @param Closure $dataClosure |
||
161 | * |
||
162 | * @return void |
||
163 | * |
||
164 | * @throws DBALException |
||
165 | */ |
||
166 | 1 | protected function seedModelsData(int $records, string $modelClass, Closure $dataClosure): void |
|
172 | |||
173 | /** |
||
174 | * @param string $tableName |
||
175 | * @param array $data |
||
176 | * @param array $columnTypes |
||
177 | * |
||
178 | * @return void |
||
179 | * |
||
180 | * @throws DBALException |
||
181 | */ |
||
182 | 1 | protected function seedRowData(string $tableName, array $data, array $columnTypes = []): void |
|
188 | |||
189 | /** |
||
190 | * @param string $modelClass |
||
191 | * @param array $data |
||
192 | * |
||
193 | * @return void |
||
194 | * |
||
195 | * @throws DBALException |
||
196 | */ |
||
197 | 1 | protected function seedModelData(string $modelClass, array $data): void |
|
203 | |||
204 | /** |
||
205 | * @return string |
||
206 | */ |
||
207 | 1 | protected function getLastInsertId(): string |
|
211 | |||
212 | /** |
||
213 | * @param string $tableName |
||
214 | * @param Connection $connection |
||
215 | * @param array $data |
||
216 | * @param Closure $getColumnType |
||
217 | * |
||
218 | * @return void |
||
219 | * |
||
220 | * @throws DBALException |
||
221 | */ |
||
222 | 1 | private function insertRow($tableName, Connection $connection, array $data, Closure $getColumnType): void |
|
239 | |||
240 | /** |
||
241 | * @param array $attributeTypes |
||
242 | * |
||
243 | * @return Closure |
||
244 | */ |
||
245 | 1 | private function createAttributeTypeGetter(array $attributeTypes): Closure |
|
252 | } |
||
253 |