Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OrderStatusRepository.php 953B

123456789101112131415161718192021222324252627282930313233343536
  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. }