You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3KB

  1. <?php
  2. namespace common\logic\Order\OrderStatusHistory\Service;
  3. use common\logic\AbstractBuilder;
  4. use common\logic\Order\Order\Model\Order;
  5. use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
  6. use common\logic\User\User\Model\User;
  7. use common\logic\User\User\Service\UserSolver;
  8. class OrderStatusHistoryBuilder extends AbstractBuilder
  9. {
  10. protected UserSolver $userSolver;
  11. public function loadDependencies(): void
  12. {
  13. $this->userSolver = $this->loadService(UserSolver::class);
  14. }
  15. public function instanciateOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory
  16. {
  17. $orderStatusHistory = new OrderStatusHistory();
  18. $orderStatusHistory->populateOrder($order);
  19. $orderStatusHistory->populateUser($user);
  20. $orderStatusHistory->status = $status;
  21. $orderStatusHistory->origin = $origin;
  22. $orderStatusHistory->date = date('Y-m-d H:i:s');
  23. return $orderStatusHistory;
  24. }
  25. public function createOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory
  26. {
  27. $orderStatusHistory = $this->instanciateOrderStatusHistory($order, $user, $status, $origin);
  28. $this->saveCreate($orderStatusHistory);
  29. return $orderStatusHistory;
  30. }
  31. }