1 | <?php |
||
36 | class VariantSubject extends AbstractProductSubject |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The ID of the parent product to relate the variant with. |
||
41 | * |
||
42 | * @var integer |
||
43 | */ |
||
44 | protected $parentId; |
||
45 | |||
46 | /** |
||
47 | * The mapping for the SKUs to the created entity IDs. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $skuEntityIdMapping = array(); |
||
52 | |||
53 | /** |
||
54 | * Intializes the previously loaded global data for exactly one variants. |
||
55 | * |
||
56 | * @return void |
||
57 | * @see \Importer\Csv\Actions\ProductImportAction::prepare() |
||
58 | */ |
||
59 | public function setUp() |
||
74 | |||
75 | /** |
||
76 | * Set's the ID of the parent product to relate the variant with. |
||
77 | * |
||
78 | * @param integer $parentId The ID of the parent product |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public function setParentId($parentId) |
||
86 | |||
87 | /** |
||
88 | * Return's the ID of the parent product to relate the variant with. |
||
89 | * |
||
90 | * @return integer The ID of the parent product |
||
91 | */ |
||
92 | public function getParentId() |
||
96 | |||
97 | /** |
||
98 | * Return the entity ID for the passed SKU. |
||
99 | * |
||
100 | * @param string $sku The SKU to return the entity ID for |
||
101 | * |
||
102 | * @return integer The mapped entity ID |
||
103 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
104 | */ |
||
105 | public function mapSkuToEntityId($sku) |
||
116 | |||
117 | /** |
||
118 | * Return's the store for the passed store code. |
||
119 | * |
||
120 | * @param string $storeCode The store code to return the store for |
||
121 | * |
||
122 | * @return array The requested store |
||
123 | * @throws \Exception Is thrown, if the requested store is not available |
||
124 | */ |
||
125 | public function getStoreByStoreCode($storeCode) |
||
136 | |||
137 | /** |
||
138 | * Return's the first EAV attribute for the passed option value and store ID. |
||
139 | * |
||
140 | * @param string $optionValue The option value of the EAV attributes |
||
141 | * @param string $storeId The store ID of the EAV attribues |
||
142 | * |
||
143 | * @return array The array with the EAV attribute |
||
144 | */ |
||
145 | public function getEavAttributeByOptionValueAndStoreId($optionValue, $storeId) |
||
149 | |||
150 | /** |
||
151 | * Persist's the passed product relation data and return's the ID. |
||
152 | * |
||
153 | * @param array $productRelation The product relation data to persist |
||
154 | * |
||
155 | * @return void |
||
156 | */ |
||
157 | public function persistProductRelation($productRelation) |
||
161 | |||
162 | /** |
||
163 | * Persist's the passed product super link data and return's the ID. |
||
164 | * |
||
165 | * @param array $productSuperLink The product super link data to persist |
||
166 | * |
||
167 | * @return void |
||
168 | */ |
||
169 | public function persistProductSuperLink($productSuperLink) |
||
173 | |||
174 | /** |
||
175 | * Persist's the passed product super attribute data and return's the ID. |
||
176 | * |
||
177 | * @param array $productSuperAttribute The product super attribute data to persist |
||
178 | * |
||
179 | * @return string The ID of the persisted product super attribute entity |
||
180 | */ |
||
181 | public function persistProductSuperAttribute($productSuperAttribute) |
||
185 | |||
186 | /** |
||
187 | * Persist's the passed product super attribute label data and return's the ID. |
||
188 | * |
||
189 | * @param array $productSuperAttributeLabel The product super attribute label data to persist |
||
190 | * |
||
191 | * @return void |
||
192 | */ |
||
193 | public function persistProductSuperAttributeLabel($productSuperAttributeLabel) |
||
197 | } |
||
198 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: