ameliabooking
/
src
/
Application
/
Controller
/
Mobile
/
Appointments
/
UpdateAppointmentStatusMobileController.php
GetAppointmentMobileController.php
2 weeks ago
GetAppointmentsMobileController.php
2 weeks ago
UpdateAppointmentStatusMobileController.php
2 weeks ago
UpdateAppointmentStatusMobileController.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Controller\Mobile\Appointments; |
| 4 | |
| 5 | use AmeliaBooking\Application\Commands\Booking\Appointment\UpdateAppointmentStatusCommand; |
| 6 | use AmeliaBooking\Application\Commands\CommandResult; |
| 7 | use AmeliaBooking\Application\Controller\Mobile\MobileV1Controller; |
| 8 | use AmeliaBooking\Domain\Events\DomainEventBus; |
| 9 | use AmeliaVendor\Psr\Http\Message\ServerRequestInterface as Request; |
| 10 | |
| 11 | class UpdateAppointmentStatusMobileController extends MobileV1Controller |
| 12 | { |
| 13 | public $allowedFields = ['status']; |
| 14 | |
| 15 | protected function instantiateCommand(Request $request, $args) |
| 16 | { |
| 17 | $command = new UpdateAppointmentStatusCommand($args); |
| 18 | |
| 19 | $requestBody = $request->getParsedBody(); |
| 20 | $this->setCommandFields($command, $requestBody); |
| 21 | $command->setToken($request); |
| 22 | $this->forceCabinetContext($command); |
| 23 | |
| 24 | return $command; |
| 25 | } |
| 26 | |
| 27 | protected function emitSuccessEvent(DomainEventBus $eventBus, CommandResult $result) |
| 28 | { |
| 29 | $eventBus->emit('AppointmentStatusUpdated', $result); |
| 30 | } |
| 31 | } |
| 32 |