public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiTvChannelDocument($this, $external_params);
     $this->document->controllers->add(new RESTApiTvChannelLink($this->nested_params));
     $this->document->controllers->add(new RESTApiTvChannelRecord($this->nested_params));
     $this->controllers->add(new RESTApiTvChannelLast($this->nested_params));
     $this->fields_map = array_fill_keys(array('id', "name", "number", "archive", "censored"), true);
     $this->manager = \Itv::getInstance();
     if (!empty($this->nested_params['users.id'])) {
         $user_id = $this->nested_params['users.id'];
         $user = \Stb::getById($user_id);
         if (empty($user)) {
             throw new RESTNotFound("User not found");
         }
         $this->user_id = $user['id'];
         $this->fav_channels = $this->manager->getFav($this->user_id);
         $this->user_channels = $this->manager->getAllUserChannelsIdsByUid($this->user_id);
     }
     if (!empty($this->nested_params['genre'])) {
         $genres = new \TvGenre();
         $genre = $genres->getById($this->nested_params['genre'], true);
         if (empty($genre)) {
             throw new RESTNotFound("Genre not found");
         }
         $this->genre_id = (int) $genre['id'];
     }
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiKaraokeDocument($this, $this->external_params);
     $this->document->controllers->add(new RESTApiKaraokeLink($this->nested_params));
     $this->manager = new \Karaoke();
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiEpgDocument();
     $this->document->controllers->add(new RESTApiEpgLink($this->nested_params));
     $this->document->controllers->add(new RESTApiEpgRecord($this->nested_params));
     $this->manager = new \Epg();
     $this->fields_map = array_fill_keys(array('id', "name"), true);
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->manager = \Radio::getInstance();
     if (!empty($this->nested_params['users.id'])) {
         $user_id = $this->nested_params['users.id'];
         $user = \Stb::getById($user_id);
         if (empty($user)) {
             throw new RESTNotFound("User not found");
         }
         $this->user_id = $user['id'];
     }
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiVideoDocument($this, $this->external_params);
     $this->document->controllers->add(new RESTApiVideoLink($this->nested_params));
     $this->document->controllers->add(new RESTApiVideoNotEnded($this->nested_params));
     $this->fields_map = array_fill_keys(array('id', "name", "description", "director", "actors", "year", "censored", "added", "genres", "genres_ids", "cover", "hd"), true);
     $this->manager = new \Video();
     if (!empty($this->nested_params['users.id'])) {
         $user_id = $this->nested_params['users.id'];
         $user = \Stb::getById($user_id);
         if (empty($user)) {
             throw new RESTNotFound("User nor found");
         }
         $user_obj = \User::getInstance();
         $this->favorites = $user_obj->getVideoFavorites();
         $this->not_ended = $user_obj->getNotEndedVideo();
     }
     if (!empty($this->nested_params['video.category']) && empty($this->nested_params['video.genre'])) {
         $category_id = $this->nested_params['video.category'];
         $genre = new \VideoGenre();
         $genres = $genre->getByCategoryId($category_id, true);
         if (empty($genres)) {
             throw new RESTNotFound("Genres list is empty");
         }
         $this->genres_ids = array_map(function ($genre) {
             return (int) $genre['_id'];
         }, $genres);
     } else {
         if (!empty($this->nested_params['video.genre']) && empty($this->nested_params['video.category'])) {
             $genre = new \VideoGenre();
             $genres = $genre->getById($this->nested_params['video.genre'], true);
             if (empty($genres)) {
                 throw new RESTNotFound("Genres list is empty");
             }
             $genres = array_map(function ($genre) {
                 return (int) $genre['id'];
             }, $genres);
             $this->genres_ids = $genres;
         } else {
             if (!empty($this->nested_params['video.genre']) && !empty($this->nested_params['video.category'])) {
                 $genre = new \VideoGenre();
                 $genres = $genre->getByIdAndCategory($this->nested_params['video.genre'], $this->nested_params['video.category'], true);
                 if (empty($genres)) {
                     throw new RESTNotFound("Genres list is empty");
                 }
                 $this->genres_ids = array($genres['id']);
             }
         }
     }
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiUsersDocument();
     $this->document->controllers->add(new RESTApiUserSettings());
     $this->document->controllers->add(new RESTApiUserPaymentInfo());
     $this->document->controllers->add(new RESTApiUserAgreement());
     $this->document->controllers->add(new RESTApiUserToS());
     $this->document->controllers->add(new RESTApiUserPing());
     $this->document->controllers->add(new RESTApiUserMediaInfo());
     $this->document->controllers->add(new RESTApiPvrSummary());
     $this->document->controllers->add(new RESTApiUserMessage());
     $this->document->controllers->add(new RESTApiUserModules());
     $this->fields_map = array_fill_keys(array('id', "ls", "status", "mac"), true);
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiVideoGenreDocument();
     if (!empty($this->nested_params['video.category'])) {
         $category = new \VideoCategory();
         $category_ids = explode(',', $this->nested_params['video.category']);
         foreach ($category_ids as $category_id) {
             $this->categories[] = $category->getById($category_id, true);
         }
         if (empty($this->categories)) {
             throw new RESTNotFound("Category not found");
         }
     }
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiTvFavoriteDocument($this, $this->external_params);
     if (empty($this->nested_params['users.id'])) {
         throw new RESTBadRequest("User must be specified");
     }
     $user_id = $this->nested_params['users.id'];
     $user = \Stb::getById($user_id);
     if (empty($user)) {
         throw new RESTNotFound("User not found");
     }
     $this->user_id = $user['id'];
     $this->manager = \Itv::getInstance();
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiPvrDocument($this, $this->external_params);
     $this->document->controllers->add(new RESTApiPvrLink($this->nested_params));
     $this->document->controllers->add(new RESTApiPvrStop($this->nested_params));
     if (!empty($this->nested_params['users.id'])) {
         $user_id = $this->nested_params['users.id'];
         $user = \Stb::getById($user_id);
         if (empty($user)) {
             throw new RESTNotFound("User not found");
         }
         $this->user_id = $user['id'];
     } else {
         throw new RESTNotAcceptable("User ID required");
     }
 }
 public function __construct(array $nested_params, array $external_params)
 {
     parent::__construct($nested_params, $external_params);
     $this->document = new RESTApiTvGenreDocument();
 }