Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
Moved the children endpoint to the item class from the section class …
Browse files Browse the repository at this point in the history
…as it is only scoped to items and makes no sense in the section base class.
  • Loading branch information
nickbart committed Dec 25, 2012
1 parent 747d307 commit df25720
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
25 changes: 25 additions & 0 deletions Server/Library/ItemAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ abstract class Plex_Server_Library_ItemAbstract
*/
protected $updatedAt;

/**
* Endpoint for listing the child items of a parent or grandparent item.
*/
const ENDPOINT_CHILDREN = 'children';

/**
* Sets an array of attribues, if they exist, to the corresponding class
* member.
Expand Down Expand Up @@ -239,6 +244,26 @@ public function getPolymorphicItem($polymorphicData)
}
}

/**
* Builds an endpoint for an item to retrieve its children and grandchildren
* items.
*
* @uses Plex_Server_Library::ENDPOINT_METADATA
* @uses Plex_Server_Library_SectionAbstract::ENDPOINT_CHILDREN
* @uses Plex_Server_Library_ItemAbstract::getRatingKey()
*
* @return string The requested children endpoint.
*/
protected function buildChildrenEndpoint()
{
return sprintf(
'%s/%d/%s',
Plex_Server_Library::ENDPOINT_METADATA,
$this->getRatingKey(),
self::ENDPOINT_CHILDREN
);
}

/**
* Static factory method used to instantiate child item classes by their
* type.
Expand Down
27 changes: 1 addition & 26 deletions Server/Library/SectionAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,10 @@ abstract class Plex_Server_Library_SectionAbstract extends Plex_Server_Library
const ENDPOINT_CATEGORY_YEAR = 'year';

/**
* Endpoing for searching a section for items.
* Endpoint for searching a section for items.
*/
const ENDPOINT_SEARCH = 'search';

/**
* Endping for listing the child items of a parent or grandparent item.
*/
const ENDPOINT_CHILDREN = 'children';

/**
* Parameter for searching movies.
*/
Expand Down Expand Up @@ -295,26 +290,6 @@ protected function buildSearchEndpoint($type, $query)
return $this->buildEndpoint($endpoint);
}

/**
* Builds an endpoint for an item to retrieve its children and grandchildren
* items.
*
* @uses Plex_Server_Library::ENDPOINT_METADATA
* @uses Plex_Server_Library_SectionAbstract::ENDPOINT_CHILDREN
* @uses Plex_Server_Library_ItemAbstract::getRatingKey()
*
* @return string The requested children endpoint.
*/
protected function buildChildrenEndpoint()
{
return sprintf(
'%s/%d/%s',
Plex_Server_Library::ENDPOINT_METADATA,
$this->getRatingKey(),
self::ENDPOINT_CHILDREN
);
}

/**
* Generic method allowing a child class to retrieve all items for its
* section.
Expand Down

0 comments on commit df25720

Please sign in to comment.