Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like AbstractSubject often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractSubject, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
53 | abstract class AbstractSubject implements SubjectInterface, FilesystemSubjectInterface, DateConverterSubjectInterface |
||
54 | { |
||
55 | |||
56 | /** |
||
57 | * The trait that provides basic filesystem handling functionality. |
||
58 | * |
||
59 | * @var \TechDivision\Import\Subjects\FilesystemTrait |
||
60 | */ |
||
61 | use FilesystemTrait; |
||
62 | |||
63 | /** |
||
64 | * The trait that provides basic filesystem handling functionality. |
||
65 | * |
||
66 | * @var \TechDivision\Import\SystemLoggerTrait |
||
67 | */ |
||
68 | use SystemLoggerTrait; |
||
69 | |||
70 | /** |
||
71 | * The trait that provides date converting functionality. |
||
72 | * |
||
73 | * @var \TechDivision\Import\DateConverterTrait |
||
74 | */ |
||
75 | use DateConverterTrait; |
||
76 | |||
77 | /** |
||
78 | * The trait that provides header handling functionality. |
||
79 | * |
||
80 | * @var \TechDivision\Import\HeaderTrait |
||
81 | */ |
||
82 | use HeaderTrait; |
||
83 | |||
84 | /** |
||
85 | * The trait that provides row handling functionality. |
||
86 | * |
||
87 | * @var \TechDivision\Import\RowTrait |
||
88 | */ |
||
89 | use RowTrait; |
||
90 | |||
91 | /** |
||
92 | * The unique identifier for the actual invocation. |
||
93 | * |
||
94 | * @var string |
||
95 | */ |
||
96 | protected $uniqueId; |
||
97 | |||
98 | /** |
||
99 | * The name of the file to be imported. |
||
100 | * |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $filename; |
||
104 | |||
105 | /** |
||
106 | * The actual line number. |
||
107 | * |
||
108 | * @var integer |
||
109 | */ |
||
110 | protected $lineNumber = 0; |
||
111 | |||
112 | /** |
||
113 | * The import adapter instance. |
||
114 | * |
||
115 | * @var \TechDivision\Import\Adapter\ImportAdapterInterface |
||
116 | */ |
||
117 | protected $importAdapter; |
||
118 | |||
119 | /** |
||
120 | * The subject configuration. |
||
121 | * |
||
122 | * @var \TechDivision\Import\Configuration\SubjectConfigurationInterface |
||
123 | */ |
||
124 | protected $configuration; |
||
125 | |||
126 | /** |
||
127 | * The plugin configuration. |
||
128 | * |
||
129 | * @var \TechDivision\Import\Configuration\PluginConfigurationInterface |
||
130 | */ |
||
131 | protected $pluginConfiguration; |
||
132 | |||
133 | /** |
||
134 | * The RegistryProcessor instance to handle running threads. |
||
135 | * |
||
136 | * @var \TechDivision\Import\Services\RegistryProcessorInterface |
||
137 | */ |
||
138 | protected $registryProcessor; |
||
139 | |||
140 | /** |
||
141 | * The actions unique serial. |
||
142 | * |
||
143 | * @var string |
||
144 | */ |
||
145 | protected $serial; |
||
146 | |||
147 | /** |
||
148 | * Array with the subject's observers. |
||
149 | * |
||
150 | * @var array |
||
151 | */ |
||
152 | protected $observers = array(); |
||
153 | |||
154 | /** |
||
155 | * Array with the subject's callbacks. |
||
156 | * |
||
157 | * @var array |
||
158 | */ |
||
159 | protected $callbacks = array(); |
||
160 | |||
161 | /** |
||
162 | * The subject's callback mappings. |
||
163 | * |
||
164 | * @var array |
||
165 | */ |
||
166 | protected $callbackMappings = array(); |
||
167 | |||
168 | /** |
||
169 | * The available root categories. |
||
170 | * |
||
171 | * @var array |
||
172 | */ |
||
173 | protected $rootCategories = array(); |
||
174 | |||
175 | /** |
||
176 | * The Magento configuration. |
||
177 | * |
||
178 | * @var array |
||
179 | */ |
||
180 | protected $coreConfigData = array(); |
||
181 | |||
182 | /** |
||
183 | * The available stores. |
||
184 | * |
||
185 | * @var array |
||
186 | */ |
||
187 | protected $stores = array(); |
||
188 | |||
189 | /** |
||
190 | * The available websites. |
||
191 | * |
||
192 | * @var array |
||
193 | */ |
||
194 | protected $storeWebsites = array(); |
||
195 | |||
196 | /** |
||
197 | * The default store. |
||
198 | * |
||
199 | * @var array |
||
200 | */ |
||
201 | protected $defaultStore; |
||
202 | |||
203 | /** |
||
204 | * The store view code the create the product/attributes for. |
||
205 | * |
||
206 | * @var string |
||
207 | */ |
||
208 | protected $storeViewCode; |
||
209 | |||
210 | /** |
||
211 | * The UID generator for the core config data. |
||
212 | * |
||
213 | * @var \TechDivision\Import\Utils\Generators\GeneratorInterface |
||
214 | */ |
||
215 | protected $coreConfigDataUidGenerator; |
||
216 | |||
217 | /** |
||
218 | * UNIX timestamp with the date the last row counter has been logged. |
||
219 | * |
||
220 | * @var integer |
||
221 | */ |
||
222 | protected $lastLog = 0; |
||
223 | |||
224 | /** |
||
225 | * The number of the last line that has been logged with the row counter |
||
226 | * @var integer |
||
227 | */ |
||
228 | protected $lastLineNumber = 0; |
||
229 | |||
230 | /** |
||
231 | * The event emitter instance. |
||
232 | * |
||
233 | * @var \League\Event\EmitterInterface |
||
234 | */ |
||
235 | protected $emitter; |
||
236 | |||
237 | /** |
||
238 | * The status of the file (0 = not processed, 1 = successfully processed, 2 = processed with failure) |
||
239 | * |
||
240 | * @var array |
||
241 | */ |
||
242 | protected $status = array(); |
||
243 | |||
244 | /** |
||
245 | * The default values for the columns from the configuration. |
||
246 | * |
||
247 | * @var array |
||
248 | */ |
||
249 | protected $defaultColumnValues = array(); |
||
250 | |||
251 | /** |
||
252 | * The values of the actual column, pre-initialized with the default values. |
||
253 | * |
||
254 | * @var array |
||
255 | */ |
||
256 | protected $columnValues = array(); |
||
257 | |||
258 | /** |
||
259 | * Mapping for the virtual entity type code to the real Magento 2 EAV entity type code. |
||
260 | * |
||
261 | * @var array |
||
262 | */ |
||
263 | protected $entityTypeCodeMappings = array( |
||
264 | EntityTypeCodes::EAV_ATTRIBUTE => EntityTypeCodes::CATALOG_PRODUCT, |
||
265 | EntityTypeCodes::EAV_ATTRIBUTE_SET => EntityTypeCodes::CATALOG_PRODUCT, |
||
266 | EntityTypeCodes::CATALOG_PRODUCT_URL => EntityTypeCodes::CATALOG_PRODUCT, |
||
267 | EntityTypeCodes::CATALOG_PRODUCT_PRICE => EntityTypeCodes::CATALOG_PRODUCT, |
||
268 | EntityTypeCodes::CATALOG_PRODUCT_INVENTORY => EntityTypeCodes::CATALOG_PRODUCT, |
||
269 | EntityTypeCodes::CATALOG_PRODUCT_INVENTORY_MSI => EntityTypeCodes::CATALOG_PRODUCT, |
||
270 | EntityTypeCodes::CATALOG_PRODUCT_TIER_PRICE => EntityTypeCodes::CATALOG_PRODUCT |
||
271 | ); |
||
272 | |||
273 | /** |
||
274 | * Initialize the subject instance. |
||
275 | * |
||
276 | * @param \TechDivision\Import\Services\RegistryProcessorInterface $registryProcessor The registry processor instance |
||
277 | * @param \TechDivision\Import\Utils\Generators\GeneratorInterface $coreConfigDataUidGenerator The UID generator for the core config data |
||
278 | * @param \Doctrine\Common\Collections\Collection $systemLoggers The array with the system loggers instances |
||
279 | * @param \League\Event\EmitterInterface $emitter The event emitter instance |
||
280 | */ |
||
281 | 81 | public function __construct( |
|
292 | |||
293 | /** |
||
294 | * Return's the event emitter instance. |
||
295 | * |
||
296 | * @return \League\Event\EmitterInterface The event emitter instance |
||
297 | */ |
||
298 | 9 | public function getEmitter() |
|
302 | |||
303 | /** |
||
304 | * Set's the name of the file to import |
||
305 | * |
||
306 | * @param string $filename The filename |
||
307 | * |
||
308 | * @return void |
||
309 | */ |
||
310 | 13 | public function setFilename($filename) |
|
314 | |||
315 | /** |
||
316 | * Return's the name of the file to import. |
||
317 | * |
||
318 | * @return string The filename |
||
319 | */ |
||
320 | 12 | public function getFilename() |
|
324 | |||
325 | /** |
||
326 | * Set's the actual line number. |
||
327 | * |
||
328 | * @param integer $lineNumber The line number |
||
329 | * |
||
330 | * @return void |
||
331 | */ |
||
332 | 1 | public function setLineNumber($lineNumber) |
|
336 | |||
337 | /** |
||
338 | * Return's the actual line number. |
||
339 | * |
||
340 | * @return integer The line number |
||
341 | */ |
||
342 | 17 | public function getLineNumber() |
|
346 | |||
347 | /** |
||
348 | * Return's the default callback mappings. |
||
349 | * |
||
350 | * @return array The default callback mappings |
||
351 | */ |
||
352 | 1 | public function getDefaultCallbackMappings() |
|
356 | |||
357 | /** |
||
358 | * Load the default column values from the configuration. |
||
359 | * |
||
360 | * @return array The array with the default column values |
||
361 | */ |
||
362 | 81 | View Code Duplication | public function getDefaultColumnValues() |
382 | |||
383 | /** |
||
384 | * Load the default header mappings from the configuration. |
||
385 | * |
||
386 | * @return array The array with the default header mappings |
||
387 | */ |
||
388 | 81 | View Code Duplication | public function getDefaultHeaderMappings() |
408 | |||
409 | /** |
||
410 | * Tries to format the passed value to a valid date with format 'Y-m-d H:i:s'. |
||
411 | * If the passed value is NOT a valid date, NULL will be returned. |
||
412 | * |
||
413 | * @param string $value The value to format |
||
414 | * |
||
415 | * @return string|null The formatted date or NULL if the date is not valid |
||
416 | * @throws \InvalidArgumentException Is thrown, if the passed can not be formatted according to the configured date format |
||
417 | */ |
||
418 | public function formatDate($value) |
||
434 | |||
435 | /** |
||
436 | * Extracts the elements of the passed value by exploding them |
||
437 | * with the also passed delimiter. |
||
438 | * |
||
439 | * @param string $value The value to extract |
||
440 | * @param string|null $delimiter The delimiter used to extrace the elements |
||
441 | * |
||
442 | * @return array The exploded values |
||
443 | */ |
||
444 | public function explode($value, $delimiter = null) |
||
448 | |||
449 | /** |
||
450 | * Queries whether or not debug mode is enabled or not, default is FALSE. |
||
451 | * |
||
452 | * @return boolean TRUE if debug mode is enabled, else FALSE |
||
453 | */ |
||
454 | 1 | public function isDebugMode() |
|
458 | |||
459 | /** |
||
460 | * Queries whether or not strict mode is enabled or not, default is FALSE. |
||
461 | * |
||
462 | * @return boolean TRUE if strict mode is enabled, else FALSE |
||
463 | */ |
||
464 | public function isStrictMode() |
||
468 | |||
469 | /** |
||
470 | * Return's the subject's execution context configuration. |
||
471 | * |
||
472 | * @return \TechDivision\Import\ExecutionContextInterface The execution context configuration to use |
||
473 | */ |
||
474 | public function getExecutionContext() |
||
475 | { |
||
476 | return $this->getConfiguration()->getPluginConfiguration()->getExecutionContext(); |
||
477 | } |
||
478 | |||
479 | /** |
||
480 | * Set's the subject configuration. |
||
481 | * |
||
482 | * @param \TechDivision\Import\Configuration\SubjectConfigurationInterface $configuration The subject configuration |
||
483 | * |
||
484 | * @return void |
||
485 | */ |
||
486 | 81 | public function setConfiguration(SubjectConfigurationInterface $configuration) |
|
487 | { |
||
488 | 81 | $this->configuration = $configuration; |
|
489 | 81 | } |
|
490 | |||
491 | /** |
||
492 | * Return's the subject configuration. |
||
493 | * |
||
494 | * @return \TechDivision\Import\Configuration\SubjectConfigurationInterface The subject configuration |
||
495 | */ |
||
496 | 81 | public function getConfiguration() |
|
497 | { |
||
498 | 81 | return $this->configuration; |
|
499 | } |
||
500 | |||
501 | /** |
||
502 | * Set's the import adapter instance. |
||
503 | * |
||
504 | * @param \TechDivision\Import\Adapter\ImportAdapterInterface $importAdapter The import adapter instance |
||
505 | * |
||
506 | * @return void |
||
507 | */ |
||
508 | 1 | public function setImportAdapter(ImportAdapterInterface $importAdapter) |
|
509 | { |
||
510 | 1 | $this->importAdapter = $importAdapter; |
|
511 | 1 | } |
|
512 | |||
513 | /** |
||
514 | * Return's the import adapter instance. |
||
515 | * |
||
516 | * @return \TechDivision\Import\Adapter\ImportAdapterInterface The import adapter instance |
||
517 | */ |
||
518 | 1 | public function getImportAdapter() |
|
522 | |||
523 | /** |
||
524 | * Return's the RegistryProcessor instance to handle the running threads. |
||
525 | * |
||
526 | * @return \TechDivision\Import\Services\RegistryProcessorInterface The registry processor instance |
||
527 | */ |
||
528 | 81 | public function getRegistryProcessor() |
|
529 | { |
||
530 | 81 | return $this->registryProcessor; |
|
531 | } |
||
532 | |||
533 | /** |
||
534 | * Set's the unique serial for this import process. |
||
535 | * |
||
536 | * @param string $serial The unique serial |
||
537 | * |
||
538 | * @return void |
||
539 | */ |
||
540 | 8 | public function setSerial($serial) |
|
541 | { |
||
542 | 8 | $this->serial = $serial; |
|
543 | 8 | } |
|
544 | |||
545 | /** |
||
546 | * Return's the unique serial for this import process. |
||
547 | * |
||
548 | * @return string The unique serial |
||
549 | */ |
||
550 | 1 | public function getSerial() |
|
551 | { |
||
552 | 1 | return $this->serial; |
|
553 | } |
||
554 | |||
555 | /** |
||
556 | * Merge's the passed status into the actual one. |
||
557 | * |
||
558 | * @param array $status The status to MergeBuilder |
||
559 | * |
||
560 | * @return void |
||
561 | */ |
||
562 | 4 | public function mergeStatus(array $status) |
|
563 | { |
||
564 | 4 | $this->status = array_replace_recursive($this->status, $status); |
|
565 | 4 | } |
|
566 | |||
567 | /** |
||
568 | * Retur's the actual status. |
||
569 | * |
||
570 | * @return array The actual status |
||
571 | */ |
||
572 | public function getStatus() |
||
573 | { |
||
574 | return $this->status; |
||
575 | } |
||
576 | |||
577 | /** |
||
578 | * Return's the unique identifier for the actual invocation. |
||
579 | * |
||
580 | * @return string The unique identifier |
||
581 | */ |
||
582 | 4 | public function getUniqueId() |
|
583 | { |
||
584 | 4 | return $this->uniqueId; |
|
585 | } |
||
586 | |||
587 | /** |
||
588 | * Return's the source date format to use. |
||
589 | * |
||
590 | * @return string The source date format |
||
591 | */ |
||
592 | public function getSourceDateFormat() |
||
593 | { |
||
594 | return $this->getConfiguration()->getSourceDateFormat(); |
||
595 | } |
||
596 | |||
597 | /** |
||
598 | * Return's the multiple field delimiter character to use, default value is comma (,). |
||
599 | * |
||
600 | * @return string The multiple field delimiter character |
||
601 | */ |
||
602 | 1 | public function getMultipleFieldDelimiter() |
|
606 | |||
607 | /** |
||
608 | * Return's the multiple value delimiter character to use, default value is comma (|). |
||
609 | * |
||
610 | * @return string The multiple value delimiter character |
||
611 | */ |
||
612 | 1 | public function getMultipleValueDelimiter() |
|
613 | { |
||
614 | 1 | return $this->getConfiguration()->getMultipleValueDelimiter(); |
|
615 | } |
||
616 | |||
617 | /** |
||
618 | * Intializes the previously loaded global data for exactly one bunch. |
||
619 | * |
||
620 | * @param string $serial The serial of the actual import |
||
621 | * |
||
622 | * @return void |
||
623 | */ |
||
624 | 81 | public function setUp($serial) |
|
625 | { |
||
626 | |||
627 | // initialize the unique ID for the actual invocation |
||
628 | 81 | $this->uniqueId = Uuid::uuid4()->toString(); |
|
629 | |||
630 | // load the status of the actual import |
||
631 | 81 | $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS); |
|
632 | |||
633 | // load the global data, if prepared initially |
||
634 | 81 | if (isset($status[RegistryKeys::GLOBAL_DATA])) { |
|
635 | 81 | $this->stores = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::STORES]; |
|
636 | 81 | $this->defaultStore = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::DEFAULT_STORE]; |
|
637 | 81 | $this->storeWebsites = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::STORE_WEBSITES]; |
|
638 | 81 | $this->rootCategories = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::ROOT_CATEGORIES]; |
|
639 | 81 | $this->coreConfigData = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::CORE_CONFIG_DATA]; |
|
640 | } |
||
641 | |||
642 | // merge the header mappings with the values found in the configuration |
||
643 | 81 | $this->headerMappings = array_merge($this->headerMappings, $this->getDefaultHeaderMappings()); |
|
644 | |||
645 | // merge the callback mappings with the mappings from the child instance |
||
646 | 81 | $this->callbackMappings = array_merge($this->callbackMappings, $this->getDefaultCallbackMappings()); |
|
647 | |||
648 | // merge the default column values with the values found in the configuration |
||
649 | 81 | $this->defaultColumnValues = array_merge($this->defaultColumnValues, $this->getDefaultColumnValues()); |
|
650 | |||
651 | // load the available callbacks from the configuration |
||
652 | 81 | $availableCallbacks = $this->getConfiguration()->getCallbacks(); |
|
653 | |||
654 | // merge the callback mappings the the one from the configuration file |
||
655 | 81 | foreach ($availableCallbacks as $callbackMappings) { |
|
656 | 81 | foreach ($callbackMappings as $attributeCode => $mappings) { |
|
657 | // write a log message, that default callback configuration will |
||
658 | // be overwritten with the one from the configuration file |
||
659 | 81 | if (isset($this->callbackMappings[$attributeCode])) { |
|
660 | 81 | $this->getSystemLogger()->notice( |
|
661 | 81 | sprintf('Now override callback mappings for attribute %s with values found in configuration file', $attributeCode) |
|
662 | ); |
||
663 | } |
||
664 | |||
665 | // override the attributes callbacks |
||
666 | 81 | $this->callbackMappings[$attributeCode] = $mappings; |
|
667 | } |
||
668 | } |
||
669 | 81 | } |
|
670 | |||
671 | /** |
||
672 | * Clean up the global data after importing the variants. |
||
673 | * |
||
674 | * @param string $serial The serial of the actual import |
||
675 | * |
||
676 | * @return void |
||
677 | */ |
||
678 | 1 | public function tearDown($serial) |
|
679 | { |
||
680 | |||
681 | // load the registry processor |
||
682 | 1 | $registryProcessor = $this->getRegistryProcessor(); |
|
683 | |||
684 | // update the source directory for the next subject |
||
685 | 1 | foreach ($this->getStatus() as $key => $status) { |
|
686 | 1 | $registryProcessor->mergeAttributesRecursive($key, $status); |
|
687 | } |
||
688 | |||
689 | // log a debug message with the new source directory |
||
690 | 1 | $this->getSystemLogger()->debug( |
|
691 | 1 | sprintf('Subject %s successfully updated status data for import %s', get_class($this), $serial) |
|
692 | ); |
||
693 | 1 | } |
|
694 | |||
695 | /** |
||
696 | * Return's the target directory for the artefact export. |
||
697 | * |
||
698 | * @return string The target directory for the artefact export |
||
699 | */ |
||
700 | 1 | View Code Duplication | public function getTargetDir() |
701 | { |
||
702 | |||
703 | // load the status from the registry processor |
||
704 | 1 | $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS); |
|
705 | |||
706 | // query whether or not a target directory (mandatory) has been configured |
||
707 | 1 | if (isset($status[RegistryKeys::TARGET_DIRECTORY])) { |
|
708 | 1 | return $status[RegistryKeys::TARGET_DIRECTORY]; |
|
709 | } |
||
710 | |||
711 | // throw an exception if the root category is NOT available |
||
712 | throw new \Exception(sprintf('Can\'t find a target directory in status data for import %s', $this->getSerial())); |
||
713 | } |
||
714 | |||
715 | /** |
||
716 | * Register the passed observer with the specific type. |
||
717 | * |
||
718 | * @param \TechDivision\Import\Observers\ObserverInterface $observer The observer to register |
||
719 | * @param string $type The type to register the observer with |
||
720 | * |
||
721 | * @return void |
||
722 | */ |
||
723 | 6 | public function registerObserver(ObserverInterface $observer, $type) |
|
724 | { |
||
725 | |||
726 | // query whether or not the array with the callbacks for the |
||
727 | // passed type has already been initialized, or not |
||
728 | 6 | if (!isset($this->observers[$type])) { |
|
729 | 6 | $this->observers[$type] = array(); |
|
730 | } |
||
731 | |||
732 | // append the callback with the instance of the passed type |
||
733 | 6 | $this->observers[$type][] = $observer; |
|
734 | 6 | } |
|
735 | |||
736 | /** |
||
737 | * Register the passed callback with the specific type. |
||
738 | * |
||
739 | * @param \TechDivision\Import\Callbacks\CallbackInterface $callback The subject to register the callbacks for |
||
740 | * @param string $type The type to register the callback with |
||
741 | * |
||
742 | * @return void |
||
743 | */ |
||
744 | 2 | public function registerCallback(CallbackInterface $callback, $type) |
|
745 | { |
||
746 | |||
747 | // query whether or not the array with the callbacks for the |
||
748 | // passed type has already been initialized, or not |
||
749 | 2 | if (!isset($this->callbacks[$type])) { |
|
750 | 2 | $this->callbacks[$type] = array(); |
|
751 | } |
||
752 | |||
753 | // append the callback with the instance of the passed type |
||
754 | 2 | $this->callbacks[$type][] = $callback; |
|
755 | 2 | } |
|
756 | |||
757 | /** |
||
758 | * Return's the array with callbacks for the passed type. |
||
759 | * |
||
760 | * @param string $type The type of the callbacks to return |
||
761 | * |
||
762 | * @return array The callbacks |
||
763 | */ |
||
764 | 1 | public function getCallbacksByType($type) |
|
765 | { |
||
766 | |||
767 | // initialize the array for the callbacks |
||
768 | 1 | $callbacks = array(); |
|
769 | |||
770 | // query whether or not callbacks for the type are available |
||
771 | 1 | if (isset($this->callbacks[$type])) { |
|
772 | 1 | $callbacks = $this->callbacks[$type]; |
|
773 | } |
||
774 | |||
775 | // return the array with the type's callbacks |
||
776 | 1 | return $callbacks; |
|
777 | } |
||
778 | |||
779 | /** |
||
780 | * Return's the array with the available observers. |
||
781 | * |
||
782 | * @return array The observers |
||
783 | */ |
||
784 | 6 | public function getObservers() |
|
788 | |||
789 | /** |
||
790 | * Return's the array with the available callbacks. |
||
791 | * |
||
792 | * @return array The callbacks |
||
793 | */ |
||
794 | 1 | public function getCallbacks() |
|
798 | |||
799 | /** |
||
800 | * Return's the callback mappings for this subject. |
||
801 | * |
||
802 | * @return array The array with the subject's callback mappings |
||
803 | */ |
||
804 | 2 | public function getCallbackMappings() |
|
805 | { |
||
806 | 2 | return $this->callbackMappings; |
|
807 | } |
||
808 | |||
809 | /** |
||
810 | * Imports the content of the file with the passed filename. |
||
811 | * |
||
812 | * |
||
813 | * @param string $serial The serial of the actual import |
||
814 | * @param string $filename The filename to process |
||
815 | * |
||
816 | * @return void |
||
817 | * @throws \Exception Is thrown, if the import can't be processed |
||
818 | */ |
||
819 | 2 | public function import($serial, $filename) |
|
947 | |||
948 | /** |
||
949 | * Imports the passed row into the database. If the import failed, the exception |
||
950 | * will be catched and logged, but the import process will be continued. |
||
951 | * |
||
952 | * @param array $row The row with the data to be imported |
||
953 | * |
||
954 | * @return void |
||
955 | */ |
||
956 | 7 | public function importRow(array $row) |
|
1064 | |||
1065 | /** |
||
1066 | * Queries whether or not that the subject needs an OK file to be processed. |
||
1067 | * |
||
1068 | * @return boolean TRUE if the subject needs an OK file, else FALSE |
||
1069 | */ |
||
1070 | 1 | public function isOkFileNeeded() |
|
1074 | |||
1075 | /** |
||
1076 | * Return's the default store. |
||
1077 | * |
||
1078 | * @return array The default store |
||
1079 | */ |
||
1080 | public function getDefaultStore() |
||
1084 | |||
1085 | /** |
||
1086 | * Return's the default store view code. |
||
1087 | * |
||
1088 | * @return array The default store view code |
||
1089 | */ |
||
1090 | 5 | public function getDefaultStoreViewCode() |
|
1094 | |||
1095 | /** |
||
1096 | * Set's the store view code the create the product/attributes for. |
||
1097 | * |
||
1098 | * @param string $storeViewCode The store view code |
||
1099 | * |
||
1100 | * @return void |
||
1101 | */ |
||
1102 | 4 | public function setStoreViewCode($storeViewCode) |
|
1106 | |||
1107 | /** |
||
1108 | * Return's the store view code the create the product/attributes for. |
||
1109 | * |
||
1110 | * @param string|null $default The default value to return, if the store view code has not been set |
||
1111 | * |
||
1112 | * @return string The store view code |
||
1113 | */ |
||
1114 | 8 | public function getStoreViewCode($default = null) |
|
1131 | |||
1132 | /** |
||
1133 | * Prepare's the store view code in the subject. If the store_view_code row doesn't contain |
||
1134 | * any value, the default code of the default store view will be set. |
||
1135 | * |
||
1136 | * @return void |
||
1137 | */ |
||
1138 | 2 | public function prepareStoreViewCode() |
|
1149 | |||
1150 | /** |
||
1151 | * Return's the store ID of the store with the passed store view code |
||
1152 | * |
||
1153 | * @param string $storeViewCode The store view code to return the store ID for |
||
1154 | * |
||
1155 | * @return integer The ID of the store with the passed ID |
||
1156 | * @throws \Exception Is thrown, if the store with the actual code is not available |
||
1157 | */ |
||
1158 | 4 | public function getStoreId($storeViewCode) |
|
1176 | |||
1177 | /** |
||
1178 | * Return's the store ID of the actual row, or of the default store |
||
1179 | * if no store view code is set in the CSV file. |
||
1180 | * |
||
1181 | * @param string|null $default The default store view code to use, if no store view code is set in the CSV file |
||
1182 | * |
||
1183 | * @return integer The ID of the actual store |
||
1184 | * @throws \Exception Is thrown, if the store with the actual code is not available |
||
1185 | */ |
||
1186 | 2 | public function getRowStoreId($default = null) |
|
1197 | |||
1198 | /** |
||
1199 | * Return's the root category for the actual view store. |
||
1200 | * |
||
1201 | * @return array The store's root category |
||
1202 | * @throws \Exception Is thrown if the root category for the passed store code is NOT available |
||
1203 | */ |
||
1204 | 2 | public function getRootCategory() |
|
1218 | |||
1219 | /** |
||
1220 | * Return's the Magento configuration value. |
||
1221 | * |
||
1222 | * @param string $path The Magento path of the requested configuration value |
||
1223 | * @param mixed $default The default value that has to be returned, if the requested configuration value is not set |
||
1224 | * @param string $scope The scope the configuration value has been set |
||
1225 | * @param integer $scopeId The scope ID the configuration value has been set |
||
1226 | * |
||
1227 | * @return mixed The configuration value |
||
1228 | * @throws \Exception Is thrown, if nor a value can be found or a default value has been passed |
||
1229 | */ |
||
1230 | 5 | public function getCoreConfigData($path, $default = null, $scope = ScopeKeys::SCOPE_DEFAULT, $scopeId = 0) |
|
1306 | |||
1307 | /** |
||
1308 | * Resolve the original column name for the passed one. |
||
1309 | * |
||
1310 | * @param string $columnName The column name that has to be resolved |
||
1311 | * |
||
1312 | * @return string|null The original column name |
||
1313 | */ |
||
1314 | 2 | public function resolveOriginalColumnName($columnName) |
|
1336 | |||
1337 | /** |
||
1338 | * Return's the original data if available, or an empty array. |
||
1339 | * |
||
1340 | * @return array The original data |
||
1341 | */ |
||
1342 | 2 | public function getOriginalData() |
|
1357 | |||
1358 | /** |
||
1359 | * Query's whether or not the actual column contains original data like |
||
1360 | * filename, line number and column names. |
||
1361 | * |
||
1362 | * @return boolean TRUE if the actual column contains origin data, else FALSE |
||
1363 | */ |
||
1364 | 2 | public function hasOriginalData() |
|
1368 | |||
1369 | /** |
||
1370 | * Wraps the passed exeception into a new one by trying to resolve the original filname, |
||
1371 | * line number and column names and use it for a detailed exception message. |
||
1372 | * |
||
1373 | * @param array $columnNames The column names that should be resolved and wrapped |
||
1374 | * @param \Exception $parent The exception we want to wrap |
||
1375 | * @param string $className The class name of the exception type we want to wrap the parent one |
||
1376 | * |
||
1377 | * @return \Exception the wrapped exception |
||
1378 | */ |
||
1379 | 1 | public function wrapException( |
|
1423 | |||
1424 | /** |
||
1425 | * Strip's the exception suffix containing filename and line number from the |
||
1426 | * passed message. |
||
1427 | * |
||
1428 | * @param string $message The message to strip the exception suffix from |
||
1429 | * |
||
1430 | * @return mixed The message without the exception suffix |
||
1431 | */ |
||
1432 | 1 | public function stripExceptionSuffix($message) |
|
1436 | |||
1437 | /** |
||
1438 | * Append's the exception suffix containing filename and line number to the |
||
1439 | * passed message. If no message has been passed, only the suffix will be |
||
1440 | * returned |
||
1441 | * |
||
1442 | * @param string|null $message The message to append the exception suffix to |
||
1443 | * @param string|null $filename The filename used to create the suffix |
||
1444 | * @param string|null $lineNumber The line number used to create the suffx |
||
1445 | * |
||
1446 | * @return string The message with the appended exception suffix |
||
1447 | */ |
||
1448 | 12 | public function appendExceptionSuffix($message = null, $filename = null, $lineNumber = null) |
|
1469 | |||
1470 | /** |
||
1471 | * Raises the value for the counter with the passed key by one. |
||
1472 | * |
||
1473 | * @param mixed $counterName The name of the counter to raise |
||
1474 | * |
||
1475 | * @return integer The counter's new value |
||
1476 | */ |
||
1477 | 1 | public function raiseCounter($counterName) |
|
1486 | |||
1487 | /** |
||
1488 | * Merge the passed array into the status of the actual import. |
||
1489 | * |
||
1490 | * @param array $status The status information to be merged |
||
1491 | * |
||
1492 | * @return void |
||
1493 | */ |
||
1494 | 1 | public function mergeAttributesRecursive(array $status) |
|
1503 | |||
1504 | /** |
||
1505 | * Return's the entity type code to be used. |
||
1506 | * |
||
1507 | * @return string The entity type code to be used |
||
1508 | */ |
||
1509 | public function getEntityTypeCode() |
||
1523 | |||
1524 | /** |
||
1525 | * Concatenates and returns the event name for the actual plugin and subject context. |
||
1526 | * |
||
1527 | * @param string $eventName The event name to concatenate |
||
1528 | * |
||
1529 | * @return string The concatenated event name |
||
1530 | */ |
||
1531 | 9 | protected function getEventName($eventName) |
|
1540 | |||
1541 | /** |
||
1542 | * Return's the full opration name, which consists of the Magento edition, the entity type code and the operation name. |
||
1543 | * |
||
1544 | * @param string $separator The separator used to seperate the elements |
||
1545 | * |
||
1546 | * @return string The full operation name |
||
1547 | */ |
||
1548 | public function getFullOperationName($separator = '/') |
||
1552 | } |
||
1553 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..