Skip to content

Commit 050fcc1

Browse files
committed
Added Node model
1 parent 8c6b5e2 commit 050fcc1

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/Gitlab/Model/Node.php

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

lib/Gitlab/Model/Project.php

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

234+
public function tree(array $params = array())
235+
{
236+
$data = $this->api('repo')->tree($this->id, $params);
237+
238+
$tree = array();
239+
foreach ($data as $node) {
240+
$tree[] = Node::fromArray($this->getClient(), $this, $node);
241+
}
242+
243+
return $tree;
244+
}
245+
234246
public function events()
235247
{
236248
$data = $this->api('projects')->events($this->id);

0 commit comments

Comments
 (0)