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.

36 lines
953B

  1. <?php
  2. namespace domain\Order\OrderStatus;
  3. use domain\_\AbstractRepository;
  4. use yii\base\ErrorException;
  5. class OrderStatusRepository extends AbstractRepository
  6. {
  7. protected OrderStatusDefinition $orderStatusDefinition;
  8. public function loadDependencies(): void
  9. {
  10. $this->orderStatusDefinition = $this->loadService(OrderStatusDefinition::class);
  11. }
  12. public function getDefaultOptionsSearch(): array
  13. {
  14. return [];
  15. }
  16. public function getOrderStatusByAlias(string $alias): OrderStatus
  17. {
  18. $orderStatusArray = $this->orderStatusDefinition->getOrderStatusList();
  19. if(isset($orderStatusArray[$alias])) {
  20. return OrderStatusBuilder::getInstance()->instanciateOrderStatus(
  21. $alias,
  22. $orderStatusArray[$alias]['label']
  23. );
  24. }
  25. else {
  26. throw new ErrorException('Statut de commande introuvable : '.$alias);
  27. }
  28. }
  29. }