Skip to content

Commit 8c6b5e2

Browse files
committed
Added event Model
1 parent dcfced3 commit 8c6b5e2

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/Gitlab/Model/Event.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Gitlab\Model;
4+
5+
use Gitlab\Client;
6+
7+
class Event extends AbstractModel
8+
{
9+
protected static $_properties = array(
10+
'title',
11+
'project_id',
12+
'action_name',
13+
'target_id',
14+
'target_type',
15+
'author_id',
16+
'data',
17+
'target_title',
18+
'project'
19+
);
20+
21+
public static function fromArray(Client $client, Project $project, array $data)
22+
{
23+
$event = new Event($project, $data['id'], $client);
24+
25+
return $event->hydrate($data);
26+
}
27+
28+
public function __construct(Project $project, $id = null, Client $client = null)
29+
{
30+
$this->setClient($client);
31+
32+
$this->project = $project;
33+
$this->id = $id;
34+
}
35+
36+
}

lib/Gitlab/Model/Project.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ public function commits($page = 0, $per_page = Api::PER_PAGE, $ref_name = null)
231231
return $commits;
232232
}
233233

234+
public function events()
235+
{
236+
$data = $this->api('projects')->events($this->id);
237+
238+
$events = array();
239+
foreach ($data as $event) {
240+
$events[] = Event::fromArray($this->getClient(), $this, $event);
241+
}
242+
}
243+
234244
public function mergeRequests($page = 1, $per_page = Api::PER_PAGE)
235245
{
236246
$data = $this->api('mr')->all($this->id, $page, $per_page);

0 commit comments

Comments
 (0)