Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/core/DrPublishApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,21 @@ public function getCategory($id)
return $this->createDrPublishApiClientCategory($responseObject);
}

public function searchRelations($query, $limit = 5, $offset = 0)
{
$url = '/relationships.json?' . $query . '&offset=' . $offset . '&limit=' . $limit;
$response = $this->curl($url);
$responseObject = json_decode($response->body);
$drPublishApiClientSearchList = new DrPublishApiClientSearchList($responseObject->search, $response->headers);
if (!empty($responseObject)) {
$relations = $responseObject->items;
foreach ($relations as $relationData) {
$drPublishApiClientSearchList->add($this->createDrPublishApiClientRelation($relationData));
}
}
return $drPublishApiClientSearchList;
}

public function searchSources($query, $limit = 5, $offset = 0)
{
$url = '/sources.json?' . $query . '&offset=' . $offset . '&limit=' . $limit;
Expand Down Expand Up @@ -482,6 +497,11 @@ public function createDrPublishApiClientCategory($category)
return new DrPublishApiClientCategory($category, $this);
}

public function createDrPublishApiClientRelation($relation)
{
return new DrPublishApiClientRelation($relation, $this);
}

public static function writeCache($identifier, $data)
{
$cacheFile = self::cacheDirGen($identifier, true);
Expand Down
23 changes: 23 additions & 0 deletions lib/core/entities/DrPublishApiClientRelation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
class DrPublishApiClientRelation extends DrPublishApiClientArticleEntity
{
protected $object;
protected $objectId;
protected $relationship;
protected $relationshipPriority;
protected $subject;
protected $subjectId;

public function __construct($data)
{
parent::__construct($data);
$this->relationshipPriority = $this->relationship_priority;
$this->subjectId = $this->subject_id;
$this->objectId = $this->object_id;
}

public function __toString()
{
return isset($this->$relationship) ? $this->$relationship : '';
}
}