Conditions | 9 |
Paths | 49 |
Total Lines | 375 |
Code Lines | 249 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
25 | public function up(Schema $schema) |
||
26 | { |
||
27 | $platform = $this->connection->getDatabasePlatform()->getName(); |
||
28 | $cipherService = $this->container->get('ds_encryption.service.cipher'); |
||
29 | |||
30 | switch ($platform) { |
||
31 | case 'postgresql': |
||
32 | // Schema |
||
33 | $this->addSql('CREATE SEQUENCE ds_config_id_seq INCREMENT BY 1 MINVALUE 1 START 29'); |
||
34 | $this->addSql('CREATE SEQUENCE ds_parameter_id_seq INCREMENT BY 1 MINVALUE 1 START 4'); |
||
35 | $this->addSql('CREATE SEQUENCE ds_metadata_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
||
36 | $this->addSql('CREATE SEQUENCE ds_metadata_trans_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
||
37 | $this->addSql('CREATE SEQUENCE ds_access_id_seq INCREMENT BY 1 MINVALUE 1 START 3'); |
||
38 | $this->addSql('CREATE SEQUENCE ds_access_permission_id_seq INCREMENT BY 1 MINVALUE 1 START 7'); |
||
39 | $this->addSql('CREATE SEQUENCE ds_tenant_id_seq INCREMENT BY 1 MINVALUE 1 START 2'); |
||
40 | $this->addSql('CREATE SEQUENCE app_user_oauth_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
||
41 | $this->addSql('CREATE SEQUENCE app_registration_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
||
42 | $this->addSql('CREATE SEQUENCE app_user_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
||
43 | $this->addSql('CREATE TABLE ds_config (id INT NOT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, "key" VARCHAR(255) NOT NULL, value TEXT DEFAULT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
44 | $this->addSql('CREATE UNIQUE INDEX UNIQ_758C45F4D17F50A6 ON ds_config (uuid)'); |
||
45 | $this->addSql('CREATE UNIQUE INDEX UNIQ_758C45F48A90ABA94E59C462 ON ds_config (key, tenant)'); |
||
46 | $this->addSql('CREATE TABLE ds_parameter (id INT NOT NULL, "key" VARCHAR(255) NOT NULL, value TEXT DEFAULT NULL, PRIMARY KEY(id))'); |
||
47 | $this->addSql('CREATE UNIQUE INDEX UNIQ_B3C0FD91F48571EB ON ds_parameter ("key")'); |
||
48 | $this->addSql('CREATE TABLE ds_metadata (id INT NOT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, slug VARCHAR(255) NOT NULL, type VARCHAR(255) DEFAULT NULL, data JSON NOT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
49 | $this->addSql('CREATE UNIQUE INDEX UNIQ_11290F17D17F50A6 ON ds_metadata (uuid)'); |
||
50 | $this->addSql('CREATE UNIQUE INDEX UNIQ_11290F17989D9B624E59C462 ON ds_metadata (slug, tenant)'); |
||
51 | $this->addSql('CREATE TABLE ds_metadata_trans (id INT NOT NULL, translatable_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
||
52 | $this->addSql('CREATE INDEX IDX_A6447E202C2AC5D3 ON ds_metadata_trans (translatable_id)'); |
||
53 | $this->addSql('CREATE UNIQUE INDEX ds_metadata_trans_unique_translation ON ds_metadata_trans (translatable_id, locale)'); |
||
54 | $this->addSql('CREATE TABLE ds_access (id INT NOT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, assignee VARCHAR(255) DEFAULT NULL, assignee_uuid UUID DEFAULT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
55 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A76F41DCD17F50A6 ON ds_access (uuid)'); |
||
56 | $this->addSql('CREATE TABLE ds_access_permission (id INT NOT NULL, access_id INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, entity VARCHAR(255) DEFAULT NULL, entity_uuid UUID DEFAULT NULL, "key" VARCHAR(255) NOT NULL, attributes JSON NOT NULL, tenant UUID NOT NULL, PRIMARY KEY(id))'); |
||
57 | $this->addSql('CREATE INDEX IDX_D46DD4D04FEA67CF ON ds_access_permission (access_id)'); |
||
58 | $this->addSql('CREATE TABLE ds_tenant (id INT NOT NULL, uuid UUID NOT NULL, data JSON NOT NULL, version INT DEFAULT 1 NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
59 | $this->addSql('CREATE UNIQUE INDEX UNIQ_EF5FAEEAD17F50A6 ON ds_tenant (uuid)'); |
||
60 | $this->addSql('CREATE TABLE app_user_oauth (id INT NOT NULL, user_id INT DEFAULT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, type VARCHAR(255) NOT NULL, identifier VARCHAR(255) NOT NULL, token VARCHAR(255) NOT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
61 | $this->addSql('CREATE UNIQUE INDEX UNIQ_B00328E0D17F50A6 ON app_user_oauth (uuid)'); |
||
62 | $this->addSql('CREATE INDEX IDX_B00328E0A76ED395 ON app_user_oauth (user_id)'); |
||
63 | $this->addSql('CREATE UNIQUE INDEX UNIQ_B00328E08CDE5729772E836A4E59C462 ON app_user_oauth (type, identifier, tenant)'); |
||
64 | $this->addSql('CREATE TABLE app_user (id INT NOT NULL, username VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) DEFAULT NULL, password VARCHAR(255) NOT NULL, last_login TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, confirmation_token VARCHAR(180) DEFAULT NULL, password_requested_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, roles TEXT NOT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, identity VARCHAR(255) DEFAULT NULL, identity_uuid UUID DEFAULT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, username_canonical VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
65 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9C05FB297 ON app_user (confirmation_token)'); |
||
66 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9D17F50A6 ON app_user (uuid)'); |
||
67 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9F85E06774E59C462 ON app_user (username, tenant)'); |
||
68 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E992FC23A84E59C462 ON app_user (username_canonical, tenant)'); |
||
69 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9E7927C744E59C462 ON app_user (email, tenant)'); |
||
70 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9A0D96FBF4E59C462 ON app_user (email_canonical, tenant)'); |
||
71 | $this->addSql('COMMENT ON COLUMN app_user.roles IS \'(DC2Type:array)\''); |
||
72 | $this->addSql('CREATE TABLE app_registration (id INT NOT NULL, user_id INT DEFAULT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, username VARCHAR(255) NOT NULL, identity VARCHAR(255) DEFAULT NULL, data JSON NOT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
73 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A026BD26D17F50A6 ON app_registration (uuid)'); |
||
74 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A026BD26A76ED395 ON app_registration (user_id)'); |
||
75 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A026BD26F85E06774E59C462 ON app_registration (username, tenant)'); |
||
76 | $this->addSql('ALTER TABLE ds_metadata_trans ADD CONSTRAINT FK_A6447E202C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES ds_metadata (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
77 | $this->addSql('ALTER TABLE ds_access_permission ADD CONSTRAINT FK_D46DD4D04FEA67CF FOREIGN KEY (access_id) REFERENCES ds_access (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
78 | $this->addSql('ALTER TABLE app_user_oauth ADD CONSTRAINT FK_B00328E0A76ED395 FOREIGN KEY (user_id) REFERENCES app_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
79 | $this->addSql('ALTER TABLE app_registration ADD CONSTRAINT FK_A026BD26A76ED395 FOREIGN KEY (user_id) REFERENCES app_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
80 | $this->addSql('CREATE TABLE ds_session (id VARCHAR(128) NOT NULL PRIMARY KEY, data BYTEA NOT NULL, time INTEGER NOT NULL, lifetime INTEGER NOT NULL)'); |
||
81 | |||
82 | // Data |
||
83 | $yml = file_get_contents('/srv/api-platform/src/AppBundle/Resources/migrations/1_0_0.yml'); |
||
84 | $data = Yaml::parse($yml); |
||
85 | $i = 0; |
||
86 | $parameters = [ |
||
87 | [ |
||
88 | 'key' => 'ds_system.user.username', |
||
89 | 'value' => serialize($data['system']['username']) |
||
90 | ], |
||
91 | [ |
||
92 | 'key' => 'ds_system.user.password', |
||
93 | 'value' => $cipherService->encrypt($data['system']['password']) |
||
94 | ], |
||
95 | [ |
||
96 | 'key' => 'ds_tenant.tenant.default', |
||
97 | 'value' => serialize($data['tenant']['uuid']) |
||
98 | ] |
||
99 | ]; |
||
100 | |||
101 | foreach ($parameters as $parameter) { |
||
102 | $this->addSql(sprintf( |
||
103 | 'INSERT INTO ds_parameter (id, key, value) VALUES (%d, %s, %s);', |
||
104 | ++$i, |
||
105 | $this->connection->quote($parameter['key']), |
||
106 | $this->connection->quote($parameter['value']) |
||
107 | )); |
||
108 | } |
||
109 | |||
110 | $i = 0; |
||
111 | $tenants = [ |
||
112 | [ |
||
113 | 'uuid' => $data['tenant']['uuid'], |
||
114 | 'data' => '"'.$cipherService->encrypt(new stdClass).'"' |
||
115 | ] |
||
116 | ]; |
||
117 | |||
118 | foreach ($tenants as $tenant) { |
||
119 | $this->addSql(sprintf( |
||
120 | 'INSERT INTO ds_tenant (id, uuid, data, created_at, updated_at) VALUES (%d, %s, %s, %s, %s);', |
||
121 | ++$i, |
||
122 | $this->connection->quote($tenant['uuid']), |
||
123 | $this->connection->quote($tenant['data']), |
||
124 | 'now()', |
||
125 | 'now()' |
||
126 | )); |
||
127 | } |
||
128 | |||
129 | $i = 0; |
||
130 | $configs = [ |
||
131 | [ |
||
132 | 'key' => 'ds_api.user.username', |
||
133 | 'value' => serialize($data['user']['system']['username']) |
||
134 | ], |
||
135 | [ |
||
136 | 'key' => 'ds_api.user.password', |
||
137 | 'value' => $cipherService->encrypt($data['user']['system']['password']) |
||
138 | ], |
||
139 | [ |
||
140 | 'key' => 'ds_api.user.uuid', |
||
141 | 'value' => serialize($data['user']['system']['uuid']) |
||
142 | ], |
||
143 | [ |
||
144 | 'key' => 'ds_api.user.roles', |
||
145 | 'value' => serialize([]) |
||
146 | ], |
||
147 | [ |
||
148 | 'key' => 'ds_api.user.identity.roles', |
||
149 | 'value' => serialize([]) |
||
150 | ], |
||
151 | [ |
||
152 | 'key' => 'ds_api.user.identity.type', |
||
153 | 'value' => serialize('System') |
||
154 | ], |
||
155 | [ |
||
156 | 'key' => 'ds_api.user.identity.uuid', |
||
157 | 'value' => serialize($data['identity']['system']['uuid']) |
||
158 | ], |
||
159 | [ |
||
160 | 'key' => 'ds_api.user.tenant', |
||
161 | 'value' => serialize($data['tenant']['uuid']) |
||
162 | ], |
||
163 | [ |
||
164 | 'key' => 'app.spa.admin', |
||
165 | 'value' => serialize($data['config']['app.spa.admin']['value']) |
||
166 | ], |
||
167 | [ |
||
168 | 'key' => 'app.spa.portal', |
||
169 | 'value' => serialize($data['config']['app.spa.portal']['value']) |
||
170 | ], |
||
171 | [ |
||
172 | 'key' => 'app.spa.portal.oauth.success', |
||
173 | 'value' => serialize($data['config']['app.spa.portal.oauth.success']['value']) |
||
174 | ], |
||
175 | [ |
||
176 | 'key' => 'app.registration.individual.owner.type', |
||
177 | 'value' => serialize('BusinessUnit') |
||
178 | ], |
||
179 | [ |
||
180 | 'key' => 'app.registration.individual.owner.uuid', |
||
181 | 'value' => serialize($data['business_unit']['administration']['uuid']) |
||
182 | ], |
||
183 | [ |
||
184 | 'key' => 'app.registration.individual.data.github', |
||
185 | 'value' => serialize(new stdClass) |
||
186 | ], |
||
187 | [ |
||
188 | 'key' => 'app.registration.individual.data.google', |
||
189 | 'value' => serialize(new stdClass) |
||
190 | ], |
||
191 | [ |
||
192 | 'key' => 'app.registration.individual.data.twitter', |
||
193 | 'value' => serialize(new stdClass) |
||
194 | ], |
||
195 | [ |
||
196 | 'key' => 'app.registration.individual.roles', |
||
197 | 'value' => serialize([]) |
||
198 | ], |
||
199 | [ |
||
200 | 'key' => 'app.registration.individual.enabled', |
||
201 | 'value' => serialize(true) |
||
202 | ], |
||
203 | [ |
||
204 | 'key' => 'app.registration.organization.owner.type', |
||
205 | 'value' => serialize('BusinessUnit') |
||
206 | ], |
||
207 | [ |
||
208 | 'key' => 'app.registration.organization.owner.uuid', |
||
209 | 'value' => serialize($data['business_unit']['administration']['uuid']) |
||
210 | ], |
||
211 | [ |
||
212 | 'key' => 'app.registration.organization.data.github', |
||
213 | 'value' => serialize(new stdClass) |
||
214 | ], |
||
215 | [ |
||
216 | 'key' => 'app.registration.organization.data.google', |
||
217 | 'value' => serialize(new stdClass) |
||
218 | ], |
||
219 | [ |
||
220 | 'key' => 'app.registration.organization.data.twitter', |
||
221 | 'value' => serialize(new stdClass) |
||
222 | ], |
||
223 | [ |
||
224 | 'key' => 'app.registration.organization.roles', |
||
225 | 'value' => serialize([]) |
||
226 | ], |
||
227 | [ |
||
228 | 'key' => 'app.registration.organization.enabled', |
||
229 | 'value' => serialize(true) |
||
230 | ], |
||
231 | [ |
||
232 | 'key' => 'app.resetting.email.subject', |
||
233 | 'value' => serialize('app.resetting.email.subject') |
||
234 | ], |
||
235 | [ |
||
236 | 'key' => 'app.resetting.email.body.plain', |
||
237 | 'value' => serialize('app.resetting.email.body.plain') |
||
238 | ], |
||
239 | [ |
||
240 | 'key' => 'app.resetting.email.body.html', |
||
241 | 'value' => serialize('app.resetting.email.body.html') |
||
242 | ] |
||
243 | ]; |
||
244 | |||
245 | foreach ($configs as $config) { |
||
246 | $this->addSql(sprintf( |
||
247 | 'INSERT INTO ds_config (id, uuid, owner, owner_uuid, key, value, version, tenant, created_at, updated_at) VALUES (%d, %s, %s, %s, %s, %s, %d, %s, %s, %s);', |
||
248 | ++$i, |
||
249 | $this->connection->quote(Uuid::uuid4()->toString()), |
||
250 | $this->connection->quote('BusinessUnit'), |
||
251 | $this->connection->quote($data['business_unit']['administration']['uuid']), |
||
252 | $this->connection->quote($config['key']), |
||
253 | $this->connection->quote($config['value']), |
||
254 | 1, |
||
255 | $this->connection->quote($data['tenant']['uuid']), |
||
256 | 'now()', |
||
257 | 'now()' |
||
258 | )); |
||
259 | } |
||
260 | |||
261 | $i = 0; |
||
262 | $j = 0; |
||
263 | $accesses = [ |
||
264 | [ |
||
265 | 'owner' => 'System', |
||
266 | 'owner_uuid' => $data['identity']['system']['uuid'], |
||
267 | 'assignee' => 'System', |
||
268 | 'assignee_uuid' => $data['identity']['system']['uuid'], |
||
269 | 'permissions' => [ |
||
270 | [ |
||
271 | 'key' => 'entity', |
||
272 | 'attributes' => '["BROWSE","READ","EDIT","ADD","DELETE"]' |
||
273 | ], |
||
274 | [ |
||
275 | 'key' => 'property', |
||
276 | 'attributes' => '["BROWSE","READ","EDIT"]' |
||
277 | ], |
||
278 | [ |
||
279 | 'key' => 'generic', |
||
280 | 'attributes' => '["BROWSE","READ","EDIT","ADD","DELETE","EXECUTE"]' |
||
281 | ] |
||
282 | ] |
||
283 | ], |
||
284 | [ |
||
285 | 'owner' => 'BusinessUnit', |
||
286 | 'owner_uuid' => $data['business_unit']['administration']['uuid'], |
||
287 | 'assignee' => 'Staff', |
||
288 | 'assignee_uuid' => $data['identity']['admin']['uuid'], |
||
289 | 'permissions' => [ |
||
290 | [ |
||
291 | 'key' => 'entity', |
||
292 | 'attributes' => '["BROWSE","READ","EDIT","ADD","DELETE"]' |
||
293 | ], |
||
294 | [ |
||
295 | 'key' => 'property', |
||
296 | 'attributes' => '["BROWSE","READ","EDIT"]' |
||
297 | ], |
||
298 | [ |
||
299 | 'key' => 'generic', |
||
300 | 'attributes' => '["BROWSE","READ","EDIT","ADD","DELETE","EXECUTE"]' |
||
301 | ] |
||
302 | ] |
||
303 | ] |
||
304 | ]; |
||
305 | |||
306 | foreach ($accesses as $access) { |
||
307 | $this->addSql(sprintf( |
||
308 | 'INSERT INTO ds_access (id, uuid, owner, owner_uuid, assignee, assignee_uuid, version, tenant, created_at, updated_at) VALUES (%d, %s, %s, %s, %s, %s, %d, %s, %s, %s);', |
||
309 | ++$i, |
||
310 | $this->connection->quote(Uuid::uuid4()->toString()), |
||
311 | $this->connection->quote($access['owner']), |
||
312 | $this->connection->quote($access['owner_uuid']), |
||
313 | $this->connection->quote($access['assignee']), |
||
314 | $this->connection->quote($access['assignee_uuid']), |
||
315 | 1, |
||
316 | $this->connection->quote($data['tenant']['uuid']), |
||
317 | 'now()', |
||
318 | 'now()' |
||
319 | )); |
||
320 | |||
321 | foreach ($access['permissions'] as $permission) { |
||
322 | $this->addSql(sprintf( |
||
323 | 'INSERT INTO ds_access_permission (id, access_id, scope, entity, entity_uuid, key, attributes, tenant) VALUES (%d, %d, %s, %s, %s, %s, %s, %s);', |
||
324 | ++$j, |
||
325 | $i, |
||
326 | $this->connection->quote('generic'), |
||
327 | 'NULL', |
||
328 | 'NULL', |
||
329 | $this->connection->quote($permission['key']), |
||
330 | $this->connection->quote($permission['attributes']), |
||
331 | $this->connection->quote($data['tenant']['uuid']) |
||
332 | )); |
||
333 | } |
||
334 | } |
||
335 | |||
336 | $i = 0; |
||
337 | $users = [ |
||
338 | [ |
||
339 | 'username' => '[email protected]', |
||
340 | 'password' => password_hash($data['user']['system']['password'], PASSWORD_BCRYPT), |
||
341 | 'uuid' => $data['user']['system']['uuid'], |
||
342 | 'owner' => 'System', |
||
343 | 'owner_uuid' => $data['identity']['system']['uuid'], |
||
344 | 'identity' => 'System', |
||
345 | 'identity_uuid' => $data['identity']['system']['uuid'] |
||
346 | ], |
||
347 | [ |
||
348 | 'username' => '[email protected]', |
||
349 | 'password' => password_hash($data['user']['anonymous']['password'], PASSWORD_BCRYPT), |
||
350 | 'uuid' => $data['user']['anonymous']['uuid'], |
||
351 | 'owner' => 'BusinessUnit', |
||
352 | 'owner_uuid' => $data['business_unit']['administration']['uuid'], |
||
353 | 'identity' => 'Anonymous', |
||
354 | 'identity_uuid' => null |
||
355 | ], |
||
356 | [ |
||
357 | 'username' => '[email protected]', |
||
358 | 'password' => password_hash($data['user']['admin']['password'], PASSWORD_BCRYPT), |
||
359 | 'uuid' => $data['user']['admin']['uuid'], |
||
360 | 'owner' => 'BusinessUnit', |
||
361 | 'owner_uuid' => $data['business_unit']['administration']['uuid'], |
||
362 | 'identity' => 'Staff', |
||
363 | 'identity_uuid' => $data['identity']['admin']['uuid'] |
||
364 | ] |
||
365 | ]; |
||
366 | |||
367 | foreach ($users as $user) { |
||
368 | $this->addSql(sprintf( |
||
369 | 'INSERT INTO app_user (id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, uuid, owner, owner_uuid, identity, identity_uuid, version, tenant, created_at, updated_at, deleted_at) VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s);', |
||
370 | ++$i, |
||
371 | $this->connection->quote($user['username']), |
||
372 | $this->connection->quote($user['username']), |
||
373 | $this->connection->quote($user['username']), |
||
374 | $this->connection->quote($user['username']), |
||
375 | 'true', |
||
376 | 'NULL', |
||
377 | $this->connection->quote($user['password']), |
||
378 | 'NULL', |
||
379 | 'NULL', |
||
380 | 'NULL', |
||
381 | $this->connection->quote('a:1:{i:0;s:0:"";}'), |
||
382 | $this->connection->quote($user['uuid']), |
||
383 | $this->connection->quote($user['owner']), |
||
384 | $this->connection->quote($user['owner_uuid']), |
||
385 | $this->connection->quote($user['identity']), |
||
386 | null === $user['identity_uuid'] ? 'NULL' : $this->connection->quote($user['identity_uuid']), |
||
387 | 1, |
||
388 | $this->connection->quote($data['tenant']['uuid']), |
||
389 | 'now()', |
||
390 | 'now()', |
||
391 | 'NULL' |
||
392 | )); |
||
393 | } |
||
394 | |||
395 | break; |
||
396 | |||
397 | default: |
||
398 | $this->abortIf(true,'Migration cannot be executed on "'.$platform.'".'); |
||
399 | break; |
||
400 | } |
||
448 |