mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-01 21:47:44 +00:00
WIP first try for sending update command for ticket
This commit is contained in:
parent
41896b1dd4
commit
def75cec6c
@ -15,13 +15,18 @@ use Chill\TicketBundle\Action\Ticket\ChangeEmergencyStateCommand;
|
||||
use Chill\TicketBundle\Entity\EmergencyStatusHistory;
|
||||
use Chill\TicketBundle\Entity\Ticket;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Component\Mercure\HubInterface;
|
||||
use Symfony\Component\Mercure\Update;
|
||||
|
||||
/**
|
||||
* Handler for changing the emergency status of a ticket.
|
||||
*/
|
||||
class ChangeEmergencyStateCommandHandler
|
||||
{
|
||||
public function __construct(private readonly ClockInterface $clock) {}
|
||||
public function __construct(
|
||||
private readonly ClockInterface $clock,
|
||||
private readonly HubInterface $hub,
|
||||
) {}
|
||||
|
||||
public function __invoke(Ticket $ticket, ChangeEmergencyStateCommand $command): Ticket
|
||||
{
|
||||
@ -38,12 +43,20 @@ class ChangeEmergencyStateCommandHandler
|
||||
}
|
||||
|
||||
// Create a new emergency status history with the new status
|
||||
new EmergencyStatusHistory(
|
||||
$emergency = new EmergencyStatusHistory(
|
||||
$command->newEmergencyStatus,
|
||||
$ticket,
|
||||
$this->clock->now(),
|
||||
);
|
||||
|
||||
$this->hub->publish(
|
||||
new Update(
|
||||
sprintf('https//chill.social/ticket/%d', $ticket->getId()),
|
||||
json_encode(['emergency' => $emergency->getEmergencyStatus()]),
|
||||
private: true
|
||||
)
|
||||
);
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user