findOneByCode($statusCode); } return self::$statusModelCache[$statusCode]; } /** * Return the list of order status IDs for which an order is considered as not paid * * @return array */ public static function getNotPaidStatusIdList() { return self::getStatusIdList(OrderStatus::CODE_NOT_PAID); } /** * Return the list of order status IDs for which an order is considered as paid * * @return array */ public static function getPaidStatusIdList() { return self::getStatusIdList(OrderStatus::CODE_PAID); } /** * Return the list of order status IDs for which an order is considered as in process * * @return array */ public static function getProcessingStatusIdList() { return self::getStatusIdList(OrderStatus::CODE_PROCESSING); } /** * Return the list of order status IDs for which an order is considered as sent * * @return array */ public static function getSentStatusIdList() { return self::getStatusIdList(OrderStatus::CODE_SENT); } /** * Return the list of order status IDs for which an order is considered as canceled * * @return array */ public static function getCanceledStatusIdList() { return self::getStatusIdList(OrderStatus::CODE_CANCELED); } /** * Return the list of order status IDs for which an order is considered as refunded * * @return array */ public static function getRefundedStatusIdList() { return self::getStatusIdList(OrderStatus::CODE_REFUNDED); } /** * Return a list of status IDs which match $statusCode value. * * @param string $statusCode the satus code * @return array */ public static function getStatusIdList($statusCode) { if (! isset(self::$statusIdListsCache[$statusCode])) { $statusIdList = []; $statusList = OrderStatusQuery::create()->find(); /** @var OrderStatus $status */ foreach ($statusList as $status) { switch ($statusCode) { case OrderStatus::CODE_NOT_PAID: $match = $status->isNotPaid(false); break; case OrderStatus::CODE_PAID: $match = $status->isPaid(false); break; case OrderStatus::CODE_PROCESSING: $match = $status->isProcessing(false); break; case OrderStatus::CODE_SENT: $match = $status->isSent(false); break; case OrderStatus::CODE_CANCELED: $match = $status->isCancelled(false); break; case OrderStatus::CODE_REFUNDED: $match = $status->isRefunded(false); break; default: throw new InvalidArgumentException("Status code '$statusCode' is not a valid value."); } if ($match) { $statusIdList[] = $status->getId(); } } self::$statusIdListsCache[$statusCode] = $statusIdList; } return self::$statusIdListsCache[$statusCode]; } } // OrderStatusQuery