46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
|
|
class CertStatusUpdated implements ShouldBroadcastNow
|
|
{
|
|
/**
|
|
* @param string $id Eindeutiger Task-Key (z.B. "task:issue-cert:10.10.70.58")
|
|
* @param string $state queued|running|done|failed
|
|
* @param string $message Menschlich lesbarer Status-Text
|
|
* @param int $progress 0..100
|
|
* @param array $meta frei: ['domain'=>..., 'mode'=>..., 'final'=>true, ...]
|
|
*/
|
|
public function __construct(
|
|
public string $id,
|
|
public string $state,
|
|
public string $message,
|
|
public int $progress = 0,
|
|
public array $meta = [],
|
|
) {}
|
|
|
|
public function broadcastOn(): Channel
|
|
{
|
|
return new Channel('system.tasks');
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'cert.status';
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'state' => $this->state, // queued|running|done|failed
|
|
'message' => $this->message,
|
|
'progress' => $this->progress, // 0..100
|
|
'meta' => $this->meta, // beliebige Zusatzinfos
|
|
];
|
|
}
|
|
}
|