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.

RotatingBuilder.php 1.2KB

pirms 5 mēnešiem
pirms 5 mēnešiem
pirms 5 mēnešiem
12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace domain\Product\Rotating;
  3. use domain\_\AbstractBuilder;
  4. use domain\_\StatusInterface;
  5. use domain\Producer\Producer\Producer;
  6. use domain\Product\RotatingProduct\RotatingProductRepository;
  7. class RotatingBuilder extends AbstractBuilder
  8. {
  9. protected RotatingProductRepository $rotatingProductRepository;
  10. public function loadDependencies(): void
  11. {
  12. $this->rotatingProductRepository = $this->loadService(RotatingProductRepository::class);
  13. }
  14. public function instanciateRotating(Producer $producer): Rotating
  15. {
  16. $rotating = new Rotating();
  17. $rotating->setProducer($producer);
  18. $rotating->setStatus(StatusInterface::STATUS_ONLINE);
  19. return $rotating;
  20. }
  21. public function initSelectedProductsIds(Rotating $rotating): void
  22. {
  23. $selectedProductsIdsArray = [];
  24. $rotatingProductsArray = $this->rotatingProductRepository->findRotatingProductsByRotating($rotating);
  25. foreach($rotatingProductsArray as $rotatingProduct) {
  26. $selectedProductsIdsArray[] = $rotatingProduct->getProduct()->id;
  27. }
  28. $rotating->setSelectedProductsIds($selectedProductsIdsArray);
  29. }
  30. }