Grav\Plugin\Admin\Admin::lastBackup PHP Méthode

lastBackup() public méthode

Search in the logs when was the latest backup made
public lastBackup ( ) : array
Résultat array Array containing the latest backup information
    public function lastBackup()
    {
        $file = JsonFile::instance($this->grav['locator']->findResource("log://backup.log"));
        $content = $file->content();
        if (empty($content)) {
            return ['days' => '∞', 'chart_fill' => 100, 'chart_empty' => 0];
        }
        $backup = new \DateTime();
        $backup->setTimestamp($content['time']);
        $diff = $backup->diff(new \DateTime());
        $days = $diff->days;
        $chart_fill = $days > 30 ? 100 : round($days / 30 * 100);
        return ['days' => $days, 'chart_fill' => $chart_fill, 'chart_empty' => 100 - $chart_fill];
    }