/** * Lists all movies in the library, optionally filtered */ public function actionIndex() { // Get the appropriate request parameters from the filter $filterForm = new MovieFilterForm(); $movies = VideoLibrary::getMovies($filterForm->buildRequestParameters()); $this->renderIndex($movies, $filterForm); }
/** * @return array list of all movie directors */ public static function getDirectors() { // Fetch the list of all movies $movies = VideoLibrary::getMovies(array('properties' => array('director'))); $directors = array(); foreach ($movies as $movie) { $directors = array_merge($directors, $movie->director); } // We want this to be an array with just values, the keys don't matter return array_values(array_unique($directors)); }
/** * Returns the typeahead data for the movie name field */ public function actionGetMovieNames() { $cacheId = 'MovieFilterMovieNameTypeahead'; $this->renderJson($this->getTypeaheadSource($cacheId, function () { $movies = VideoLibrary::getMovies(array('properties' => array('year', 'genre', 'thumbnail'))); // Modify some of the raw data so it's ready for rendering foreach ($movies as $movie) { $thumbnail = ThumbnailFactory::create($movie->thumbnail, Thumbnail::SIZE_VERY_SMALL); $movie->thumbnail = LazyImage::image($thumbnail->getUrl()); $movie->genre = $movie->getGenreString(); } return $movies; })); }