Você não pode selecionar mais de 25 tópicos
Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
|
- <?php
-
- namespace domain\Product\RotatingProduct;
-
- use domain\_\AbstractBuilder;
- use domain\_\StatusInterface;
- use domain\Product\Rotating\Rotating;
-
- class RotatingProductBuilder extends AbstractBuilder
- {
- protected RotatingProductRepository $rotatingProductRepository;
-
- public function loadDependencies(): void
- {
- $this->rotatingProductRepository = $this->loadService(RotatingProductRepository::class);
- }
-
- public function instanciateRotatingProduct(Rotating $rotating): RotatingProduct
- {
- $rotatingProduct = new RotatingProduct();
- $rotatingProduct
- ->setRotating($rotating)
- ->setStatus(StatusInterface::STATUS_ONLINE);
-
- return $rotatingProduct;
- }
-
- public function initRotatingProductPosition(RotatingProduct $rotatingProduct): RotatingProduct
- {
- $lastRotatingProduct = $this->rotatingProductRepository->findOneLastRotatingProduct($rotatingProduct->getRotating());
- if($lastRotatingProduct) {
- $rotatingProduct->setPosition($lastRotatingProduct->getPosition() + 1);
- }
- else {
- $rotatingProduct->setPosition(1);
- }
-
- return $rotatingProduct;
- }
- }
|