1 | <?php |
||
43 | class UrlKeyObserver extends AbstractProductImportObserver |
||
44 | { |
||
45 | |||
46 | /** |
||
47 | * The trait that provides string => URL key conversion functionality. |
||
48 | * |
||
49 | * @var \TechDivision\Import\Utils\Filter\UrlKeyFilterTrait |
||
50 | */ |
||
51 | use UrlKeyFilterTrait; |
||
52 | |||
53 | /** |
||
54 | * The URL key utility instance. |
||
55 | * |
||
56 | * @var \TechDivision\Import\Utils\UrlKeyUtilInterface |
||
57 | */ |
||
58 | protected $urlKeyUtil; |
||
59 | |||
60 | /** |
||
61 | * The product bunch processor instance. |
||
62 | * |
||
63 | * @var \TechDivision\Import\Product\Services\ProductBunchProcessorInterface |
||
64 | */ |
||
65 | protected $productBunchProcessor; |
||
66 | |||
67 | /** |
||
68 | * Initialize the observer with the passed product bunch processor and filter instance. |
||
69 | * |
||
70 | * @param \TechDivision\Import\Product\Services\ProductBunchProcessorInterface $productBunchProcessor The product bunch processor instance |
||
71 | * @param \Zend\Filter\FilterInterface $convertLiteralUrlFilter The URL filter instance |
||
72 | * @param \TechDivision\Import\Utils\UrlKeyUtilInterface $urlKeyUtil The URL key utility instance |
||
73 | */ |
||
74 | public function __construct( |
||
83 | |||
84 | /** |
||
85 | * Return's the product bunch processor instance. |
||
86 | * |
||
87 | * @return \TechDivision\Import\Product\Services\ProductBunchProcessorInterface The product bunch processor instance |
||
88 | */ |
||
89 | protected function getProductBunchProcessor() |
||
93 | |||
94 | /** |
||
95 | * Process the observer's business logic. |
||
96 | * |
||
97 | * @return void |
||
98 | * @throws \Exception Is thrown, if either column "url_key" or "name" have a value set |
||
99 | */ |
||
100 | protected function process() |
||
162 | |||
163 | /** |
||
164 | * Extract's the category from the comma separeted list of categories from |
||
165 | * the column `categories` and return's an array with their URL paths. |
||
166 | * |
||
167 | * @return string[] Array with the URL paths of the categories found in column `categories` |
||
168 | * @todo The list has to be exended by the URL paths of the parent categories that has the anchor flag been acitvated |
||
169 | */ |
||
170 | protected function getUrlPaths() |
||
189 | |||
190 | /** |
||
191 | * Temporarily persist's the IDs of the passed product. |
||
192 | * |
||
193 | * @param array $product The product to temporarily persist the IDs for |
||
194 | * |
||
195 | * @return void |
||
196 | */ |
||
197 | protected function setIds(array $product) |
||
201 | |||
202 | /** |
||
203 | * Set's the ID of the product that has been created recently. |
||
204 | * |
||
205 | * @param string $lastEntityId The entity ID |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | protected function setLastEntityId($lastEntityId) |
||
213 | |||
214 | /** |
||
215 | * Return's the PK to of the product. |
||
216 | * |
||
217 | * @return integer The PK to create the relation with |
||
218 | */ |
||
219 | protected function getPrimaryKey() |
||
223 | |||
224 | /** |
||
225 | * Load's and return's the product with the passed SKU. |
||
226 | * |
||
227 | * @param string $sku The SKU of the product to load |
||
228 | * |
||
229 | * @return array The product |
||
230 | */ |
||
231 | protected function loadProduct($sku) |
||
235 | |||
236 | /** |
||
237 | * Load's and return's the url_key with the passed primary ID. |
||
238 | * |
||
239 | * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject The subject to load the URL key |
||
240 | * @param int $primaryKeyId The ID from product |
||
241 | * |
||
242 | * @return string|null url_key or null |
||
243 | */ |
||
244 | protected function loadUrlKey(UrlKeyAwareSubjectInterface $subject, $primaryKeyId) |
||
248 | |||
249 | /** |
||
250 | * Return's the category with the passed path. |
||
251 | * |
||
252 | * @param string $path The path of the category to return |
||
253 | * |
||
254 | * @return array The category |
||
255 | */ |
||
256 | protected function getCategoryByPath($path) |
||
260 | |||
261 | /** |
||
262 | * Returns the URL key utility instance. |
||
263 | * |
||
264 | * @return \TechDivision\Import\Utils\UrlKeyUtilInterface The URL key utility instance |
||
265 | */ |
||
266 | protected function getUrlKeyUtil() |
||
270 | |||
271 | /** |
||
272 | * Make's the passed URL key unique by adding the next number to the end. |
||
273 | * |
||
274 | * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject The subject to make the URL key unique for |
||
275 | * @param string $urlKey The URL key to make unique |
||
276 | * |
||
277 | * @return string The unique URL key |
||
278 | */ |
||
279 | protected function makeUnique(UrlKeyAwareSubjectInterface $subject, $urlKey) |
||
283 | } |
||
284 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: