|
- <?php
-
- namespace common\logic\Order\OrderStatusHistory\Service;
-
- use common\logic\AbstractBuilder;
- use common\logic\Order\Order\Model\Order;
- use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
- use common\logic\User\User\Model\User;
- use common\logic\User\User\Service\UserSolver;
-
- class OrderStatusHistoryBuilder extends AbstractBuilder
- {
- protected UserSolver $userSolver;
-
- public function loadDependencies(): void
- {
- $this->userSolver = $this->loadService(UserSolver::class);
- }
-
- public function instanciateOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory
- {
- $orderStatusHistory = new OrderStatusHistory();
- $orderStatusHistory->populateOrder($order);
- $orderStatusHistory->populateUser($user);
- $orderStatusHistory->status = $status;
- $orderStatusHistory->origin = $origin;
- $orderStatusHistory->date = date('Y-m-d H:i:s');
-
- return $orderStatusHistory;
- }
-
- public function createOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory
- {
- $orderStatusHistory = $this->instanciateOrderStatusHistory($order, $user, $status, $origin);
- $this->saveCreate($orderStatusHistory);
-
- return $orderStatusHistory;
- }
- }
|