1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
4
|
|
|
/** |
5
|
|
|
* A developer who has access to the system. |
6
|
|
|
* |
7
|
|
|
* phpMyAdmin Error reporting server |
8
|
|
|
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
9
|
|
|
* |
10
|
|
|
* Licensed under The MIT License |
11
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
12
|
|
|
* Redistributions of files must retain the above copyright notice. |
13
|
|
|
* |
14
|
|
|
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
15
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License |
16
|
|
|
* |
17
|
|
|
* @see https://www.phpmyadmin.net/ |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace App\Model\Table; |
21
|
|
|
|
22
|
|
|
use Cake\ORM\Table; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* A developer who has access to the system. |
26
|
|
|
*/ |
27
|
|
|
class DevelopersTable extends Table |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* creates a developer record given his github info and his access token. |
31
|
|
|
* |
32
|
|
|
* @param array $githubInfo the data gitub has on this developer |
33
|
|
|
* @param string $accessToken this developer's access token |
34
|
|
|
* @param mixed $developer |
35
|
|
|
* |
36
|
|
|
* @return bool true if the developer was correctly saved otherwise false |
37
|
|
|
*/ |
38
|
2 |
|
public function saveFromGithub($githubInfo, $accessToken, $developer) |
39
|
|
|
{ |
40
|
2 |
|
$developer->full_name = $githubInfo['name']; |
41
|
2 |
|
$developer->gravatar_id = $githubInfo['gravatar_id']; |
42
|
2 |
|
$developer->email = $githubInfo['email']; |
43
|
2 |
|
$developer->github_id = $githubInfo['id']; |
44
|
2 |
|
$developer->access_token = $accessToken; |
45
|
2 |
|
$developer->has_commit_access = $githubInfo['has_commit_access'] ? 1 : 0; |
46
|
2 |
|
if ($this->save($developer)) { |
47
|
2 |
|
return $developer->id; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|