1 | <?php |
||
14 | class ProductMapper |
||
15 | { |
||
16 | const FIELD_SKU = "sku"; |
||
17 | const FIELD_SLUG = "slug"; |
||
18 | |||
19 | /** |
||
20 | * @var array $mandatoryFields A list of all mandatory fields of a Product |
||
21 | */ |
||
22 | private $mandatoryFields = [self::FIELD_SKU, self::FIELD_SLUG]; |
||
23 | |||
24 | /** |
||
25 | * @var ContentMapper |
||
26 | */ |
||
27 | private $contentMapper; |
||
28 | |||
29 | /** |
||
30 | * Creates a new ProductMapper instance |
||
31 | * |
||
32 | * @param ContentMapper $contentMapper A class for mapping product content |
||
33 | */ |
||
34 | 7 | public function __construct(ContentMapper $contentMapper) |
|
38 | |||
39 | /** |
||
40 | * Get a Catalog model from an array of unstructured product data |
||
41 | * |
||
42 | * @param array $productData An array containing product attributes |
||
43 | * |
||
44 | * @return Product |
||
45 | * |
||
46 | * @throws ProductException If a mandatory field is missing |
||
47 | * @throws ProductException If the no Product could be created from the given product data |
||
48 | */ |
||
49 | 7 | public function getProduct(array $productData) |
|
78 | } |