Conditions | 5 |
Paths | 4 |
Total Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function run($request) |
||
15 | { |
||
16 | $users = $this->ldapService->getUsers(['objectguid', 'mail']); |
||
17 | $start = time(); |
||
18 | $count = 0; |
||
19 | |||
20 | foreach ($users as $user) { |
||
21 | // Empty mail attribute for the user, nothing we can do. Skip! |
||
22 | if (empty($user['mail'])) { |
||
23 | continue; |
||
24 | } |
||
25 | |||
26 | $member = Member::get()->where( |
||
27 | sprintf('"Email" = \'%s\' AND "GUID" IS NULL', Convert::raw2sql($user['mail'])) |
||
28 | )->first(); |
||
29 | |||
30 | if (!($member && $member->exists())) { |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | // Member was found, migrate them by setting the GUID field |
||
35 | $member->GUID = $user['objectguid']; |
||
36 | $member->write(); |
||
37 | |||
38 | $count++; |
||
39 | |||
40 | $this->log(sprintf( |
||
41 | 'Migrated Member %s (ID: %s, Email: %s)', |
||
42 | $member->getName(), |
||
43 | $member->ID, |
||
44 | $member->Email |
||
45 | )); |
||
46 | } |
||
47 | |||
48 | $end = time() - $start; |
||
49 | |||
50 | $this->log(sprintf('Done. Migrated %s Member records. Duration: %s seconds', $count, round($end, 0))); |
||
51 | } |
||
52 | |||
59 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.