|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lc\CaracoleBundle\Generator; |
|
|
namespace Lc\CaracoleBundle\Generator; |
|
|
|
|
|
|
|
|
|
|
|
use App\Solver\Order\OrderShopSolver; |
|
|
use Lc\CaracoleBundle\Definition\SectionSettingDefinition; |
|
|
use Lc\CaracoleBundle\Definition\SectionSettingDefinition; |
|
|
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; |
|
|
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; |
|
|
use Lc\CaracoleBundle\Model\Section\SectionModel; |
|
|
use Lc\CaracoleBundle\Model\Section\SectionModel; |
|
|
|
|
|
|
|
|
class OrderReferenceGenerator |
|
|
class OrderReferenceGenerator |
|
|
{ |
|
|
{ |
|
|
protected SettingSolver $settingSolver; |
|
|
protected SettingSolver $settingSolver; |
|
|
|
|
|
protected OrderShopSolver $orderShopSolver; |
|
|
|
|
|
|
|
|
public function __construct(SettingSolver $settingSolver) |
|
|
|
|
|
|
|
|
public function __construct(SettingSolver $settingSolver, OrderShopSolver $orderShopSolver) |
|
|
{ |
|
|
{ |
|
|
$this->settingSolver = $settingSolver; |
|
|
$this->settingSolver = $settingSolver; |
|
|
|
|
|
$this->orderShopSolver= $orderShopSolver; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function buildReference(OrderShopInterface $orderShop): string |
|
|
public function buildReference(OrderShopInterface $orderShop): string |
|
|
|
|
|
|
|
|
$complementaryIndex = null; |
|
|
$complementaryIndex = null; |
|
|
|
|
|
|
|
|
if ($orderShop->getMainOrderShop()) { |
|
|
if ($orderShop->getMainOrderShop()) { |
|
|
$complementaryIndex = 1; |
|
|
|
|
|
|
|
|
$complementaryIndex = 0; |
|
|
foreach ($orderShop->getMainOrderShop()->getComplementaryOrderShops() as $complementaryOrder) { |
|
|
foreach ($orderShop->getMainOrderShop()->getComplementaryOrderShops() as $complementaryOrder) { |
|
|
if ($complementaryOrder->isValid()) $complementaryIndex++; |
|
|
|
|
|
|
|
|
if ($this->orderShopSolver->isValid($complementaryOrder)) $complementaryIndex++; |
|
|
} |
|
|
} |
|
|
$orderShop = $complementaryOrder->getMainOrderShop(); |
|
|
$orderShop = $complementaryOrder->getMainOrderShop(); |
|
|
|
|
|
|