1 | <?php |
||
39 | class UrlRewriteUpdateObserver extends UrlRewriteObserver |
||
40 | { |
||
41 | |||
42 | /** |
||
43 | * Array with the existing URL rewrites of the actual product. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $existingUrlRewrites = array(); |
||
48 | |||
49 | /** |
||
50 | * Process the observer's business logic. |
||
51 | * |
||
52 | * @return void |
||
53 | * @see \TechDivision\Import\Product\UrlRewrite\Observers\UrlRewriteObserver::process() |
||
54 | */ |
||
55 | 1 | protected function process() |
|
163 | |||
164 | /** |
||
165 | * Remove's the passed URL rewrite from the existing one's. |
||
166 | * |
||
167 | * @param array $urlRewrite The URL rewrite to remove |
||
168 | * |
||
169 | * @return void |
||
170 | */ |
||
171 | protected function removeExistingUrlRewrite(array $urlRewrite) |
||
182 | |||
183 | /** |
||
184 | * Prepare's the URL rewrites that has to be created/updated. |
||
185 | * |
||
186 | * @return void |
||
187 | * @see \TechDivision\Import\Product\UrlRewrite\Observers\UrlRewriteObserver::prepareUrlRewrites() |
||
188 | */ |
||
189 | 1 | protected function prepareUrlRewrites() |
|
190 | { |
||
191 | |||
192 | // (re-)initialize the array for the existing URL rewrites |
||
193 | 1 | $this->existingUrlRewrites = array(); |
|
194 | |||
195 | // prepare the new URL rewrites first |
||
196 | 1 | parent::prepareUrlRewrites(); |
|
197 | |||
198 | // load the store ID to use |
||
199 | 1 | $storeId = $this->getSubject()->getRowStoreId(); |
|
|
|||
200 | |||
201 | // load the existing URL rewrites of the actual entity |
||
202 | 1 | $existingUrlRewrites = $this->getUrlRewritesByEntityTypeAndEntityIdAndStoreId( |
|
203 | 1 | UrlRewriteObserver::ENTITY_TYPE, |
|
204 | 1 | $this->entityId, |
|
205 | $storeId |
||
206 | ); |
||
207 | |||
208 | // prepare the existing URL rewrites to improve searching them by request path |
||
209 | 1 | foreach ($existingUrlRewrites as $existingUrlRewrite) { |
|
210 | 1 | $this->existingUrlRewrites[$existingUrlRewrite[MemberNames::REQUEST_PATH]] = $existingUrlRewrite; |
|
211 | } |
||
212 | 1 | } |
|
213 | |||
214 | /** |
||
215 | * Initialize the category product with the passed attributes and returns an instance. |
||
216 | * |
||
217 | * @param array $attr The category product attributes |
||
218 | * |
||
219 | * @return array The initialized category product |
||
220 | */ |
||
221 | 1 | protected function initializeUrlRewrite(array $attr) |
|
244 | |||
245 | /** |
||
246 | * Extracts the category ID of the passed URL rewrite entity, if available, and return's it. |
||
247 | * |
||
248 | * @param array $attr The URL rewrite entity to extract and return the category ID for |
||
249 | * |
||
250 | * @return integer|null The category ID if available, else NULL |
||
251 | */ |
||
252 | 1 | protected function getCategoryIdFromMetadata(array $attr) |
|
261 | |||
262 | /** |
||
263 | * Initialize the URL rewrite product => category relation with the passed attributes |
||
264 | * and returns an instance. |
||
265 | * |
||
266 | * @param array $attr The URL rewrite product => category relation attributes |
||
267 | * |
||
268 | * @return array|null The initialized URL rewrite product => category relation |
||
269 | */ |
||
270 | 1 | protected function initializeUrlRewriteProductCategory($attr) |
|
281 | |||
282 | /** |
||
283 | * Return's the unserialized metadata of the passed URL rewrite. If the |
||
284 | * metadata doesn't contain a category ID, the category ID of the root |
||
285 | * category will be added. |
||
286 | * |
||
287 | * @param array $urlRewrite The URL rewrite to return the metadata for |
||
288 | * |
||
289 | * @return array The metadata of the passed URL rewrite |
||
290 | */ |
||
291 | 1 | protected function getMetadata($urlRewrite) |
|
315 | |||
316 | /** |
||
317 | * Return's the category with the passed ID. |
||
318 | * |
||
319 | * @param integer $categoryId The ID of the category to return |
||
320 | * @param string $storeViewCode The store view code of the category to return, defaults to "admin" |
||
321 | * |
||
322 | * @return array The category data |
||
323 | */ |
||
324 | 1 | protected function getCategory($categoryId, $storeViewCode = StoreViewCodes::ADMIN) |
|
328 | |||
329 | /** |
||
330 | * Return's the URL rewrites for the passed URL entity type and ID. |
||
331 | * |
||
332 | * @param string $entityType The entity type to load the URL rewrites for |
||
333 | * @param integer $entityId The entity ID to load the URL rewrites for |
||
334 | * @param integer $storeId The store ID to load the URL rewrites for |
||
335 | * |
||
336 | * @return array The URL rewrites |
||
337 | */ |
||
338 | 1 | protected function getUrlRewritesByEntityTypeAndEntityIdAndStoreId($entityType, $entityId, $storeId) |
|
342 | |||
343 | /** |
||
344 | * Return's the URL rewrite product category relation for the passed |
||
345 | * URL rewrite ID. |
||
346 | * |
||
347 | * @param integer $urlRewriteId The URL rewrite ID to load the URL rewrite product category relation for |
||
348 | * |
||
349 | * @return array|false The URL rewrite product category relations |
||
350 | */ |
||
351 | 1 | protected function loadUrlRewriteProductCategory($urlRewriteId) |
|
355 | |||
356 | /** |
||
357 | * Delete's the URL rewrite with the passed attributes. |
||
358 | * |
||
359 | * @param array $row The attributes of the entity to delete |
||
360 | * @param string|null $name The name of the prepared statement that has to be executed |
||
361 | * |
||
362 | * @return void |
||
363 | */ |
||
364 | protected function deleteUrlRewrite($row, $name = null) |
||
368 | } |
||
369 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.