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() |
||
173 | |||
174 | /** |
||
175 | * Extract's the category from the comma separeted list of categories from |
||
176 | * the column `categories` and return's an array with their URL paths. |
||
177 | * |
||
178 | * @return string[] Array with the URL paths of the categories found in column `categories` |
||
179 | * @todo The list has to be exended by the URL paths of the parent categories that has the anchor flag been acitvated |
||
180 | */ |
||
181 | protected function getUrlPaths() |
||
200 | |||
201 | /** |
||
202 | * Temporarily persist's the IDs of the passed product. |
||
203 | * |
||
204 | * @param array $product The product to temporarily persist the IDs for |
||
205 | * |
||
206 | * @return void |
||
207 | */ |
||
208 | protected function setIds(array $product) |
||
212 | |||
213 | /** |
||
214 | * Set's the ID of the product that has been created recently. |
||
215 | * |
||
216 | * @param string $lastEntityId The entity ID |
||
217 | * |
||
218 | * @return void |
||
219 | */ |
||
220 | protected function setLastEntityId($lastEntityId) |
||
224 | |||
225 | /** |
||
226 | * Return's the PK to of the product. |
||
227 | * |
||
228 | * @return integer The PK to create the relation with |
||
229 | */ |
||
230 | protected function getPrimaryKey() |
||
234 | |||
235 | /** |
||
236 | * Load's and return's the product with the passed SKU. |
||
237 | * |
||
238 | * @param string $sku The SKU of the product to load |
||
239 | * |
||
240 | * @return array The product |
||
241 | */ |
||
242 | protected function loadProduct($sku) |
||
246 | |||
247 | /** |
||
248 | * Load's and return's the url_key with the passed primary ID. |
||
249 | * |
||
250 | * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject The subject to load the URL key |
||
251 | * @param int $primaryKeyId The ID from product |
||
252 | * |
||
253 | * @return string|null url_key or null |
||
254 | */ |
||
255 | protected function loadUrlKey(UrlKeyAwareSubjectInterface $subject, $primaryKeyId) |
||
259 | |||
260 | /** |
||
261 | * Return's the category with the passed path. |
||
262 | * |
||
263 | * @param string $path The path of the category to return |
||
264 | * |
||
265 | * @return array The category |
||
266 | */ |
||
267 | protected function getCategoryByPath($path) |
||
271 | |||
272 | /** |
||
273 | * Returns the URL key utility instance. |
||
274 | * |
||
275 | * @return \TechDivision\Import\Utils\UrlKeyUtilInterface The URL key utility instance |
||
276 | */ |
||
277 | protected function getUrlKeyUtil() |
||
281 | |||
282 | /** |
||
283 | * Make's the passed URL key unique by adding the next number to the end. |
||
284 | * |
||
285 | * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject The subject to make the URL key unique for |
||
286 | * @param string $urlKey The URL key to make unique |
||
287 | * |
||
288 | * @return string The unique URL key |
||
289 | */ |
||
290 | protected function makeUnique(UrlKeyAwareSubjectInterface $subject, $urlKey) |
||
294 | } |
||
295 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.