Skip to content

Commit 80a8936

Browse files
committed
Added support for ProjectIssue.
1 parent b070bf5 commit 80a8936

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/DrupalClient.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ public function getNode($id) {
5656
return $this->getResource('node', $id);
5757
}
5858

59+
/**
60+
* @param $id
61+
* @return \EclipseGc\DrupalOrg\Api\Resources\Node\ProjectIssue;
62+
*/
63+
public function getProjectIssue($id) {
64+
return $this->getResource('project_issue', $id);
65+
}
66+
5967
/**
6068
* @param $id
6169
* @return \EclipseGc\DrupalOrg\Api\Resources\TaxonomyTerm
6270
*/
6371
public function getTaxonomyTerm($id) {
6472
return $this->getResource('taxonomy_term', $id);
6573
}
66-
}
74+
}

src/Factory.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Factory implements FactoryInterface {
1414
'user' => '\EclipseGc\DrupalOrg\Api\Resources\User',
1515
'node' => '\EclipseGc\DrupalOrg\Api\Resources\Node',
1616
'taxonomy_term' => '\EclipseGc\DrupalOrg\Api\Resources\TaxonomyTerm',
17+
'project_issue' => '\EclipseGc\DrupalOrg\Api\Resources\Node\ProjectIssue',
1718
);
1819

1920
function __construct(Client $client) {
@@ -29,6 +30,7 @@ public function getObjectTypeClass($type, array $data) {
2930
}
3031

3132
public function createObjectType($type, array $data = array()) {
33+
$data = (isset($data['list'])) ? $data['list'][0] : $data;
3234
$objectClass = $this->getObjectTypeClass($type, $data);
3335
$reflector = new \ReflectionClass($objectClass);
3436
if (!isset($data['factory'])) {
@@ -51,7 +53,14 @@ public function createObjectType($type, array $data = array()) {
5153
* @throws \Exception
5254
*/
5355
public function request($entity_type, $id) {
54-
$request = $this->client()->get(['{entity_type}/{id}', ['entity_type' => $entity_type, 'id' => $id]]);
56+
switch ($entity_type) {
57+
case 'project_issue':
58+
$request = $this->client()->get(['node.json?type={entity_type}&nid={id}', ['entity_type' => $entity_type, 'id' => $id]]);
59+
break;
60+
default:
61+
$request = $this->client()->get(['{entity_type}/{id}', ['entity_type' => $entity_type, 'id' => $id]]);
62+
break;
63+
}
5564
if ($request->getStatusCode() != 200) {
5665
throw new \Exception(sprintf('Status code was not OK. %d returned instead.', $request->getStatusCode()));
5766
}
@@ -76,4 +85,4 @@ protected function client(Client $new_client = NULL) {
7685
return $client;
7786
}
7887

79-
}
88+
}

0 commit comments

Comments
 (0)