33 lines
946 B
PHP
33 lines
946 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\CardDav\CardDavContactSyncService;
|
|
use Illuminate\Console\Command;
|
|
use Throwable;
|
|
|
|
class SyncCardDavContactsCommand extends Command
|
|
{
|
|
protected $signature = 'contacts:sync-carddav';
|
|
|
|
protected $description = 'Synchronise les contacts depuis le carnet CardDAV configure.';
|
|
|
|
public function handle(CardDavContactSyncService $syncService): int
|
|
{
|
|
try {
|
|
$run = $syncService->sync();
|
|
} catch (Throwable $exception) {
|
|
$this->error('Synchronisation CardDAV en echec : '.$exception->getMessage());
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->info((string) $run->message);
|
|
$this->line('Contacts lus : '.$run->fetched_contacts);
|
|
$this->line('Contacts synchronises : '.$run->synced_contacts);
|
|
$this->line('Contacts supprimes localement : '.$run->deleted_contacts);
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|