Skip to content

Commit

Permalink
Merge pull request #147 from kichetof/main
Browse files Browse the repository at this point in the history
fix issue with `spatie/laravel-backup` v9
  • Loading branch information
freekmurze authored Dec 9, 2024
2 parents f96660d + fbdf5e9 commit 8b7ff98
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Http/Controllers/BackupStatusesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BackupStatusesController extends ApiController
public function index()
{
return Cache::remember('backup-statuses', now()->addSeconds(4), function () {
return BackupDestinationStatusFactory::createForMonitorConfig(config('backup.monitor_backups'))
return BackupDestinationStatusFactory::createForMonitorConfig($this->getMonitorConfig())
->map(function (BackupDestinationStatus $backupDestinationStatus) {
return [
'name' => $backupDestinationStatus->backupDestination()->backupName(),
Expand All @@ -30,4 +30,20 @@ public function index()
->toArray();
});
}

/**
* Get monitor configuration data.
* spatie/laravel-backup ^9.x introduce DTO parameter instead of array.
*
* @return \Spatie\Backup\Config\MonitoredBackupsConfig|array
*/
protected function getMonitorConfig()
{
$reflection = new \ReflectionMethod(BackupDestinationStatusFactory::class, 'createForMonitorConfig');
$monitorBackupsType = $reflection->getParameters()[0]->getType()->getName();

return $monitorBackupsType === 'Spatie\Backup\Config\MonitoredBackupsConfig'
? \Spatie\Backup\Config\MonitoredBackupsConfig::fromArray(config('backup.monitor_backups'))
: config('backup.monitor_backups');
}
}

0 comments on commit 8b7ff98

Please sign in to comment.