1 | <?php |
||
43 | class UrlKeyAndPathObserver extends AbstractCategoryImportObserver |
||
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 category bunch processor instance. |
||
62 | * |
||
63 | * @var \TechDivision\Import\Category\Services\CategoryBunchProcessorInterface |
||
64 | */ |
||
65 | protected $categoryBunchProcessor; |
||
66 | |||
67 | /** |
||
68 | * Initialize the observer with the passed product bunch processor instance. |
||
69 | * |
||
70 | * @param \TechDivision\Import\Category\Services\CategoryBunchProcessorInterface $categoryBunchProcessor The category 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( |
||
85 | |||
86 | /** |
||
87 | * Process the observer's business logic. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | protected function process() |
||
182 | |||
183 | /** |
||
184 | * Return the primary key member name. |
||
185 | * |
||
186 | * @return string The primary key member name |
||
187 | */ |
||
188 | protected function getPkMemberName() |
||
192 | |||
193 | /** |
||
194 | * Returns the category bunch processor instance. |
||
195 | * |
||
196 | * @return \TechDivision\Import\Category\Services\CategoryBunchProcessorInterface The category bunch processor instance |
||
197 | */ |
||
198 | protected function getCategoryBunchProcessor() |
||
202 | |||
203 | /** |
||
204 | * Returns the URL key utility instance. |
||
205 | * |
||
206 | * @return \TechDivision\Import\Utils\UrlKeyUtilInterface The URL key utility instance |
||
207 | */ |
||
208 | protected function getUrlKeyUtil() |
||
212 | |||
213 | /** |
||
214 | * Return's the category with the passed path. |
||
215 | * |
||
216 | * @param string $path The path of the category to return |
||
217 | * |
||
218 | * @return array The category |
||
219 | * @throws \Exception Is thrown, if the requested category is not available |
||
220 | */ |
||
221 | protected function getCategoryByPath($path) |
||
225 | |||
226 | /** |
||
227 | * Returns the category with the passed primary key and the attribute values for the passed store ID. |
||
228 | * |
||
229 | * @param string $pk The primary key of the category to return |
||
230 | * @param integer $storeId The store ID of the category values |
||
231 | * |
||
232 | * @return array|null The category data |
||
233 | */ |
||
234 | protected function getCategoryByPkAndStoreId($pk, $storeId) |
||
238 | |||
239 | /** |
||
240 | * Temporarily persist's the IDs of the passed category. |
||
241 | * |
||
242 | * @param array $category The category to temporarily persist the IDs for |
||
243 | * |
||
244 | * @return void |
||
245 | */ |
||
246 | protected function setIds(array $category) |
||
250 | |||
251 | /** |
||
252 | * Set's the ID of the category that has been created recently. |
||
253 | * |
||
254 | * @param string $lastEntityId The entity ID |
||
255 | * |
||
256 | * @return void |
||
257 | */ |
||
258 | protected function setLastEntityId($lastEntityId) |
||
262 | |||
263 | /** |
||
264 | * Return's the PK to of the product. |
||
265 | * |
||
266 | * @return integer The PK to create the relation with |
||
267 | */ |
||
268 | protected function getPrimaryKey() |
||
272 | |||
273 | /** |
||
274 | * Load's and return's the url_key with the passed primary ID. |
||
275 | * |
||
276 | * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject The subject to load the URL key |
||
277 | * @param int $primaryKeyId The ID from category |
||
278 | * |
||
279 | * @return string|null url_key or null |
||
280 | */ |
||
281 | protected function loadUrlKey(UrlKeyAwareSubjectInterface $subject, $primaryKeyId) |
||
285 | |||
286 | /** |
||
287 | * Make's the passed URL key unique by adding the next number to the end. |
||
288 | * |
||
289 | * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject The subject to make the URL key unique for |
||
290 | * @param string $urlKey The URL key to make unique |
||
291 | * @param array $urlPaths The URL paths to make unique |
||
292 | * |
||
293 | * @return string The unique URL key |
||
294 | */ |
||
295 | protected function makeUnique(UrlKeyAwareSubjectInterface $subject, string $urlKey, array $urlPaths = array()) |
||
299 | } |
||
300 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.