protected function get_listing_trending_unified()

in lib.php [701:739]


    protected function get_listing_trending_unified($path = '') {
        global $USER;

        $path = (empty($path)) ? '/' : $path;
        $caller = '\repository_office365::get_listing_trending_unified';
        $unified = $this->get_unified_apiclient();
        $realpath = $path;
        try {
            $o365upn = utils::get_o365_upn($USER->id);
            $filesresults = $unified->get_trending_files($o365upn);
            $contents = $filesresults['value'];
            while (!empty($filesresults['@odata.nextLink'])) {
                $nextlink = parse_url($filesresults['@odata.nextLink']);
                if (isset($nextlink['query'])) {
                    $query = [];
                    parse_str($nextlink['query'], $query);
                    if (isset($query['$skiptoken'])) {
                        $filesresults = $unified->get_trending_files($o365upn, $query['$skiptoken']);
                        $contents = array_merge($contents, $filesresults['value']);
                    }
                }
            }

            $list = $this->contents_api_response_to_list($contents, $realpath, 'trendingaround', null, false);
        } catch (\Exception $e) {
            $errmsg = 'Exception when retrieving personal trending files';
            $debugdata = [
                'fullpath' => $path,
                'message' => $e->getMessage(),
            ];
            utils::debug($errmsg, $caller, $debugdata);
            $list = [];
        }

        // Generate path.
        $strtrendingfiles = get_string('trendingaround', 'repository_office365');
        $breadcrumb = [['name' => $this->name, 'path' => '/'], ['name' => $strtrendingfiles, 'path' => '/trending/']];
        return [$list, $breadcrumb];
    }