blob: f42c9c3aa70bda91b0edbee705941ba960b53c7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?php
namespace Lti;
use User;
use Avatar;
use SimpleORMap;
/**
* @property int $id
* @property string $external_user_id
* @property string $context
* @property ?string $external_email
* @property int $mkdate
* @property int $chdate
* @property User $user
* @property ?Registration $registration
*/
class UserIdentityMapping extends SimpleORMap
{
protected static function configure($config = [])
{
$config['db_table'] = 'lti_user_identity_mappings';
$config['belongs_to']['user'] = [
'class_name' => User::class,
'foreign_key' => 'user_id',
'assoc_foreign_key' => 'user_id'
];
$config['belongs_to']['registration'] = [
'class_name' => Registration::class,
'foreign_key' => 'registration_id',
'assoc_foreign_key' => 'id'
];
parent::configure($config);
}
public function transformData(): array
{
return [
...$this->toRawArray(),
'mkdate' => date('c', $this->mkdate),
'chdate' => date('c', $this->chdate),
'user' => $this->user ? [
'id' => $this->user->id,
'name' => $this->user->getFullName(),
'username' => $this->user->username,
'avatar_url' => Avatar::getAvatar($this->user->id)->getURL(Avatar::MEDIUM)
] : []
];
}
}
|