Repository navigation
Expand file tree
/
Copy pathGroup.php
More file actions
85 lines (64 loc) · 1.9 KB
/
Copy pathGroup.php
File metadata and controls
85 lines (64 loc) · 1.9 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Gitlab\Model;
use Gitlab\Client;
class Group extends AbstractModel
{
protected static $_properties = array(
'id',
'name',
'path',
'owner_id',
'projects'
);
public static function fromArray(Client $client, array $data)
{
$group = new Group($data['id'], $client);
if (isset($data['projects'])) {
$projects = array();
foreach ($data['projects'] as $project) {
$projects[] = Project::fromArray($client, $project);
}
$data['projects'] = $projects;
}
return $group->hydrate($data);
}
public static function create(Client $client, $name, $path)
{
$data = $client->api('groups')->create($name, $path);
return Group::fromArray($client, $data);
}
public function __construct($id, Client $client = null)
{
$this->setClient($client);
$this->id = $id;
}
public function show()
{
$data = $this->api('groups')->show($this->id);
return Group::fromArray($this->getClient(), $data);
}
public function transfer($project_id)
{
$data = $this->api('groups')->transfer($this->id, $project_id);
return Group::fromArray($this->getClient(), $data);
}
public function members()
{
$data = $this->api('groups')->members($this->id);
$members = array();
foreach ($data as $member) {
$members[] = User::fromArray($this->getClient(), $member);
}
return $members;
}
public function addMember($user_id, $access_level)
{
$data = $this->api('groups')->addMember($this->id, $user_id, $access_level);
return User::fromArray($this->getClient(), $data);
}
public function removeMember($user_id)
{
$this->api('groups')->removeMember($this->id, $user_id);
return true;
}
}