Grav\Plugin\Admin\Admin::latestPages PHP Метод

latestPages() публичный Метод

Used by the Dashboard in the admin to display the X latest pages that have been modified
public latestPages ( integer $count = 10 ) : array | null
$count integer number of pages to pull back
Результат array | null
    public function latestPages($count = 10)
    {
        /** @var Pages $pages */
        $pages = $this->grav['pages'];
        $latest = [];
        if (is_null($pages->routes())) {
            return null;
        }
        foreach ($pages->routes() as $url => $path) {
            $page = $pages->dispatch($url, true);
            if ($page && $page->routable()) {
                $latest[$page->route()] = ['modified' => $page->modified(), 'page' => $page];
            }
        }
        // sort based on modified
        uasort($latest, function ($a, $b) {
            if ($a['modified'] == $b['modified']) {
                return 0;
            }
            return $a['modified'] > $b['modified'] ? -1 : 1;
        });
        // build new array with just pages in it
        $list = [];
        foreach ($latest as $item) {
            $list[] = $item['page'];
        }
        return array_slice($list, 0, $count);
    }