Commit 00faf4c5 authored by keven's avatar keven
Browse files

Added parent() relation on Stream model

parent 42d1a16f
...@@ -338,6 +338,8 @@ $stream->visibility // Visibility of the stream (public, hidden, protected) ...@@ -338,6 +338,8 @@ $stream->visibility // Visibility of the stream (public, hidden, protected)
// Stream relations // Stream relations
$stream->resources() // List the resources in the stream $stream->resources() // List the resources in the stream
$stream->hasParent() // Whether or not the Stream has a parent stream
$stream->parent() // Retrieve the parent stream, or NULL if no parent
``` ```
### Resource ### Resource
......
...@@ -43,6 +43,12 @@ class Stream extends Entity implements StreamInterface ...@@ -43,6 +43,12 @@ class Stream extends Entity implements StreamInterface
*/ */
protected $visibility = 'visible'; protected $visibility = 'visible';
/**
* @SerializedName("parent_stream")
* @Type("Libcast\Client\Entity\Link")
*/
protected $hrefParent;
/** /**
* *
* @param string $title * @param string $title
...@@ -166,4 +172,24 @@ class Stream extends Entity implements StreamInterface ...@@ -166,4 +172,24 @@ class Stream extends Entity implements StreamInterface
{ {
$this->visibility = $visibility; $this->visibility = $visibility;
} }
/**
*
* @return boolean
*/
public function hasParent()
{
return (bool) $this->hrefParent;
}
/**
*
* @return \Libcast\Client\Model\StreamInterface
*/
public function parent()
{
if ($this->hrefParent and $this->client) {
return $this->client->stream($this->hrefParent->href);
}
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment