Example #1
0
 /**
  * Override of the setion version of this method so we can apply slightly
  * different rules when retrieving single children and grandchildren at the
  * item level.
  *
  * @param integer|string $polymorphicData Either an index, a key, or a title
  * for an exact title match that will be used to retrieve a single library
  * item.
  *
  * @uses Plex_Server_Library_ItemAbstract::getItemByIndex()
  * @uses Plex_Server_Library_SectionAbstract::getPolymorphicItem()
  *
  * @return Plex_Server_Library_ItemAbstract A single Plex library item.
  */
 public function getPolymorphicItem($polymorphicData, $scopedToItem = FALSE)
 {
     // At the item level, instead of assuming an integer is a rating key, we
     // assume an integer is an index. This allows us to retrieve seasons,
     // episodes, and tracks by their number in sequence, which is a more
     // common way than by its Plex assigned rating key.
     if (is_int($polymorphicData)) {
         return $this->getItemByIndex($polymorphicData);
     } else {
         // If we're not retrieving by index, then we simply default to the
         // parent function, however, we scope it to 'item' so the calling
         // function is identified by the right depth and we use a 'get'
         // function to find the items instead of search.
         return parent::getPolymorphicItem($polymorphicData, TRUE);
     }
 }
Example #2
0
 /**
  * Returns an array of user defined Plex library sections that can be used
  * to interact with th eitems contained within.
  *
  * @uses Plex_MachineAbstract::$name
  * @uses Plex_MachineAbstract::$address
  * @uses Plex_MachineAbstract::$port
  * @uses Plex_MachineAbstract::makeCall()
  * @uses Plex_Server_Library::ENDPOINT_SECTION
  * @uses Plex_Server_Library::buildUrl()
  * @uses Plex_Server_Library_SectionAbstract::factory()
  * @uses Plex_Server_Library_SectionAbstract::setAttributes()
  *
  * @return Plex_Server_Library_Section[] An array of user defined Plex
  * library sections.
  */
 public function getSections()
 {
     $sections = array();
     $sectionArray = $this->makeCall($this->buildUrl(self::ENDPOINT_SECTION));
     foreach ($sectionArray as $attribute) {
         $section = Plex_Server_Library_SectionAbstract::factory($attribute['type'], $this->name, $this->address, $this->port);
         $section->setAttributes($attribute);
         $sections[] = $section;
     }
     return $sections;
 }