Newscoop\Services\PlaylistsService::buildNewThemePlaylists PHP Method

buildNewThemePlaylists() public method

public buildNewThemePlaylists ( $themePlaylists )
    public function buildNewThemePlaylists($themePlaylists)
    {
        if (!array_key_exists('list', $themePlaylists)) {
            return null;
        }
        $newThemePlaylists = array();
        if (array_key_exists('template', $themePlaylists['list'])) {
            $bakThemePlaylists = $themePlaylists;
            $themePlaylists = array();
            $themePlaylists['list'][0] = $bakThemePlaylists['list'];
        }
        foreach ($themePlaylists['list'] as $themePlaylist) {
            $playlistName = $themePlaylist['@attributes']['name'];
            $newThemePlaylists[$playlistName] = array();
            if (array_key_exists('@attributes', $themePlaylist['template'])) {
                $bakThemePlaylist = $themePlaylist;
                $themePlaylist = array();
                $themePlaylist['template'][0] = $bakThemePlaylist['template'];
            }
            foreach ($themePlaylist['template'] as $template) {
                $newThemePlaylists[$playlistName]['templates'][] = $template['@attributes']['file'];
            }
        }
        return $newThemePlaylists;
    }