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.
|
- <?php
-
- namespace domain\Product\Rotating;
-
- use domain\_\AbstractBuilder;
- use domain\_\StatusInterface;
- use domain\Producer\Producer\Producer;
- use domain\Product\RotatingProduct\RotatingProductRepository;
-
- class RotatingBuilder extends AbstractBuilder
- {
- protected RotatingProductRepository $rotatingProductRepository;
-
- public function loadDependencies(): void
- {
- $this->rotatingProductRepository = $this->loadService(RotatingProductRepository::class);
- }
-
- public function instanciateRotating(Producer $producer): Rotating
- {
- $rotating = new Rotating();
- $rotating->setProducer($producer);
- $rotating->setStatus(StatusInterface::STATUS_ONLINE);
-
- return $rotating;
- }
-
- public function initSelectedProductsIds(Rotating $rotating): void
- {
- $selectedProductsIdsArray = [];
- $rotatingProductsArray = $this->rotatingProductRepository->findRotatingProductsByRotating($rotating);
- foreach($rotatingProductsArray as $rotatingProduct) {
- $selectedProductsIdsArray[] = $rotatingProduct->getProduct()->id;
- }
- $rotating->setSelectedProductsIds($selectedProductsIdsArray);
- }
- }
|