1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Sylius\ShopApiPlugin\Factory; |
6
|
|
|
|
7
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
8
|
|
|
use Sylius\Component\Core\Model\ProductImageInterface; |
9
|
|
|
use Sylius\Component\Core\Model\ProductInterface; |
10
|
|
|
use Sylius\Component\Core\Model\ProductVariantInterface; |
11
|
|
|
use Sylius\Component\Product\Model\ProductAssociationInterface; |
12
|
|
|
use Sylius\ShopApiPlugin\Generator\ProductBreadcrumbGeneratorInterface; |
13
|
|
|
use Sylius\ShopApiPlugin\View\ProductVariantView; |
14
|
|
|
use Sylius\ShopApiPlugin\View\ProductView; |
15
|
|
|
|
16
|
|
|
final class DetailedProductViewFactory implements ProductViewFactoryInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var ProductViewFactoryInterface |
20
|
|
|
*/ |
21
|
|
|
private $productViewFactory; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var ProductBreadcrumbGeneratorInterface |
25
|
|
|
*/ |
26
|
|
|
private $breadcrumbGenerator; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param ProductViewFactoryInterface $productViewFactory |
30
|
|
|
* @param ProductBreadcrumbGeneratorInterface $breadcrumbGenerator |
31
|
|
|
*/ |
32
|
|
|
public function __construct( |
33
|
|
|
ProductViewFactoryInterface $productViewFactory, |
34
|
|
|
ProductBreadcrumbGeneratorInterface $breadcrumbGenerator |
35
|
|
|
) { |
36
|
|
|
$this->productViewFactory = $productViewFactory; |
37
|
|
|
$this->breadcrumbGenerator = $breadcrumbGenerator; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
|
|
public function create(ProductInterface $product, ChannelInterface $channel, string $locale): ProductView |
44
|
|
|
{ |
45
|
|
|
$productView = $this->productViewFactory->create($product, $channel, $locale); |
46
|
|
|
$productView->breadcrumb = $this->breadcrumbGenerator->generate($product, $locale); |
47
|
|
|
|
48
|
|
|
return $productView; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|