Complex classes like ProductBunchProcessor 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 ProductBunchProcessor, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
50 | class ProductBunchProcessor implements ProductBunchProcessorInterface |
||
51 | { |
||
52 | |||
53 | /** |
||
54 | * A PDO connection initialized with the values from the Doctrine EntityManager. |
||
55 | * |
||
56 | * @var \TechDivision\Import\Dbal\Connection\ConnectionInterface |
||
57 | */ |
||
58 | protected $connection; |
||
59 | |||
60 | /** |
||
61 | * The repository to access EAV attribute option values. |
||
62 | * |
||
63 | * @var \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface |
||
64 | */ |
||
65 | protected $eavAttributeOptionValueRepository; |
||
66 | |||
67 | /** |
||
68 | * The repository to access EAV attributes. |
||
69 | * |
||
70 | * @var \TechDivision\Import\Repositories\EavAttributeRepositoryInterface |
||
71 | */ |
||
72 | protected $eavAttributeRepository; |
||
73 | |||
74 | /** |
||
75 | * The action for product CRUD methods. |
||
76 | * |
||
77 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
78 | */ |
||
79 | protected $productAction; |
||
80 | |||
81 | /** |
||
82 | * The action for product varchar attribute CRUD methods. |
||
83 | * |
||
84 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
85 | */ |
||
86 | protected $productVarcharAction; |
||
87 | |||
88 | /** |
||
89 | * The action for product text attribute CRUD methods. |
||
90 | * |
||
91 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
92 | */ |
||
93 | protected $productTextAction; |
||
94 | |||
95 | /** |
||
96 | * The action for product int attribute CRUD methods. |
||
97 | * |
||
98 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
99 | */ |
||
100 | protected $productIntAction; |
||
101 | |||
102 | /** |
||
103 | * The action for product decimal attribute CRUD methods. |
||
104 | * |
||
105 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
106 | */ |
||
107 | protected $productDecimalAction; |
||
108 | |||
109 | /** |
||
110 | * The action for product datetime attribute CRUD methods. |
||
111 | * |
||
112 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
113 | */ |
||
114 | protected $productDatetimeAction; |
||
115 | |||
116 | /** |
||
117 | * The action for product website CRUD methods. |
||
118 | * |
||
119 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
120 | */ |
||
121 | protected $productWebsiteAction; |
||
122 | |||
123 | /** |
||
124 | * The action for category product relation CRUD methods. |
||
125 | * |
||
126 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
127 | */ |
||
128 | protected $categoryProductAction; |
||
129 | |||
130 | /** |
||
131 | * The action for stock item CRUD methods. |
||
132 | * |
||
133 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
134 | */ |
||
135 | protected $stockItemAction; |
||
136 | |||
137 | /** |
||
138 | * The action for URL rewrite CRUD methods. |
||
139 | * |
||
140 | * @var \TechDivision\Import\Dbal\Actions\ActionInterface |
||
141 | */ |
||
142 | protected $urlRewriteAction; |
||
143 | |||
144 | /** |
||
145 | * The repository to load the products with. |
||
146 | * |
||
147 | * @var \TechDivision\Import\Product\Repositories\ProductRepositoryInterface |
||
148 | */ |
||
149 | protected $productRepository; |
||
150 | |||
151 | /** |
||
152 | * The repository to load the product website relations with. |
||
153 | * |
||
154 | * @var \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface |
||
155 | */ |
||
156 | protected $productWebsiteRepository; |
||
157 | |||
158 | /** |
||
159 | * The repository to load the product datetime attribute with. |
||
160 | * |
||
161 | * @var \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface |
||
162 | */ |
||
163 | protected $productDatetimeRepository; |
||
164 | |||
165 | /** |
||
166 | * The repository to load the product decimal attribute with. |
||
167 | * |
||
168 | * @var \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface |
||
169 | */ |
||
170 | protected $productDecimalRepository; |
||
171 | |||
172 | /** |
||
173 | * The repository to load the product integer attribute with. |
||
174 | * |
||
175 | * @var \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface |
||
176 | */ |
||
177 | protected $productIntRepository; |
||
178 | |||
179 | /** |
||
180 | * The repository to load the product text attribute with. |
||
181 | * |
||
182 | * @var \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface |
||
183 | */ |
||
184 | protected $productTextRepository; |
||
185 | |||
186 | /** |
||
187 | * The repository to load the product varchar attribute with. |
||
188 | * |
||
189 | * @var \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface |
||
190 | */ |
||
191 | protected $productVarcharRepository; |
||
192 | |||
193 | /** |
||
194 | * The repository to load the category product relations with. |
||
195 | * |
||
196 | * @var \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface |
||
197 | */ |
||
198 | protected $categoryProductRepository; |
||
199 | |||
200 | /** |
||
201 | * The repository to load the stock item with. |
||
202 | * |
||
203 | * @var \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface |
||
204 | */ |
||
205 | protected $stockItemRepository; |
||
206 | |||
207 | /** |
||
208 | * The assembler to load the product attributes with. |
||
209 | * |
||
210 | * @var \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface |
||
211 | */ |
||
212 | protected $productAttributeAssembler; |
||
213 | |||
214 | /** |
||
215 | * The raw entity loader instance. |
||
216 | * |
||
217 | * @var \TechDivision\Import\Loaders\LoaderInterface |
||
218 | */ |
||
219 | protected $rawEntityLoader; |
||
220 | |||
221 | /** |
||
222 | * The repository to load the stock item with. |
||
223 | * |
||
224 | * @var \TechDivision\Import\Repositories\UrlRewriteRepositoryInterface |
||
225 | */ |
||
226 | protected $urlRewriteRepository; |
||
227 | |||
228 | /** |
||
229 | * Initialize the processor with the necessary assembler and repository instances. |
||
230 | * |
||
231 | * @param \TechDivision\Import\Dbal\Connection\ConnectionInterface $connection The connection to use |
||
232 | * @param \TechDivision\Import\Product\Repositories\ProductRepositoryInterface $productRepository The product repository to use |
||
233 | * @param \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface $productWebsiteRepository The product website repository to use |
||
234 | * @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface $productDatetimeRepository The product datetime repository to use |
||
235 | * @param \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface $productDecimalRepository The product decimal repository to use |
||
236 | * @param \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface $productIntRepository The product integer repository to use |
||
237 | * @param \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface $productTextRepository The product text repository to use |
||
238 | * @param \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface $productVarcharRepository The product varchar repository to use |
||
239 | * @param \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface $categoryProductRepository The category product repository to use |
||
240 | * @param \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface $stockItemRepository The stock item repository to use |
||
241 | * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The EAV attribute option value repository to use |
||
242 | * @param \TechDivision\Import\Repositories\EavAttributeRepositoryInterface $eavAttributeRepository The EAV attribute repository to use |
||
243 | * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface $eavEntityTypeRepository The EAV entity type repository to use |
||
244 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $categoryProductAction The category product action to use |
||
245 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productDatetimeAction The product datetime action to use |
||
246 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productDecimalAction The product decimal action to use |
||
247 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productIntAction The product integer action to use |
||
248 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productAction The product action to use |
||
249 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productTextAction The product text action to use |
||
250 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productVarcharAction The product varchar action to use |
||
251 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $productWebsiteAction The product website action to use |
||
252 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $stockItemAction The stock item action to use |
||
253 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $urlRewriteAction The URL rewrite action to use |
||
254 | * @param \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface $productAttributeAssembler The assembler to load the product attributes with |
||
255 | * @param \TechDivision\Import\Loaders\LoaderInterface $rawEntityLoader The raw entity loader instance |
||
256 | * @param \TechDivision\Import\Repositories\UrlRewriteRepositoryInterface $urlRewriteRepository The URL rewrite repository to use |
||
257 | */ |
||
258 | public function __construct( |
||
313 | |||
314 | /** |
||
315 | * Set's the raw entity loader instance. |
||
316 | * |
||
317 | * @param \TechDivision\Import\Loaders\LoaderInterface $rawEntityLoader The raw entity loader instance to set |
||
318 | * |
||
319 | * @return void |
||
320 | */ |
||
321 | public function setRawEntityLoader(LoaderInterface $rawEntityLoader) |
||
325 | |||
326 | /** |
||
327 | * Return's the raw entity loader instance. |
||
328 | * |
||
329 | * @return \TechDivision\Import\Loaders\LoaderInterface The raw entity loader instance |
||
330 | */ |
||
331 | public function getRawEntityLoader() |
||
335 | |||
336 | /** |
||
337 | * Set's the passed connection. |
||
338 | * |
||
339 | * @param \TechDivision\Import\Dbal\Connection\ConnectionInterface $connection The connection to set |
||
340 | * |
||
341 | * @return void |
||
342 | */ |
||
343 | public function setConnection(ConnectionInterface $connection) |
||
347 | |||
348 | /** |
||
349 | * Return's the connection. |
||
350 | * |
||
351 | * @return \TechDivision\Import\Dbal\Connection\ConnectionInterface The connection instance |
||
352 | */ |
||
353 | public function getConnection() |
||
357 | |||
358 | /** |
||
359 | * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO |
||
360 | * object instance are not committed until you end the transaction by calling ProductProcessor::commit(). |
||
361 | * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection |
||
362 | * to autocommit mode. |
||
363 | * |
||
364 | * @return boolean Returns TRUE on success or FALSE on failure |
||
365 | * @link http://php.net/manual/en/pdo.begintransaction.php |
||
366 | */ |
||
367 | public function beginTransaction() |
||
371 | |||
372 | /** |
||
373 | * Commits a transaction, returning the database connection to autocommit mode until the next call to |
||
374 | * ProductProcessor::beginTransaction() starts a new transaction. |
||
375 | * |
||
376 | * @return boolean Returns TRUE on success or FALSE on failure |
||
377 | * @link http://php.net/manual/en/pdo.commit.php |
||
378 | */ |
||
379 | public function commit() |
||
383 | |||
384 | /** |
||
385 | * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction(). |
||
386 | * |
||
387 | * If the database was set to autocommit mode, this function will restore autocommit mode after it has |
||
388 | * rolled back the transaction. |
||
389 | * |
||
390 | * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition |
||
391 | * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit |
||
392 | * COMMIT will prevent you from rolling back any other changes within the transaction boundary. |
||
393 | * |
||
394 | * @return boolean Returns TRUE on success or FALSE on failure |
||
395 | * @link http://php.net/manual/en/pdo.rollback.php |
||
396 | */ |
||
397 | public function rollBack() |
||
401 | |||
402 | /** |
||
403 | * Set's the repository to access EAV attribute option values. |
||
404 | * |
||
405 | * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The repository to access EAV attribute option values |
||
406 | * |
||
407 | * @return void |
||
408 | */ |
||
409 | public function setEavAttributeOptionValueRepository(EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository) |
||
413 | |||
414 | /** |
||
415 | * Return's the repository to access EAV attribute option values. |
||
416 | * |
||
417 | * @return \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface The repository instance |
||
418 | */ |
||
419 | public function getEavAttributeOptionValueRepository() |
||
423 | |||
424 | /** |
||
425 | * Set's the repository to access EAV attributes. |
||
426 | * |
||
427 | * @param \TechDivision\Import\Repositories\EavAttributeRepositoryInterface $eavAttributeRepository The repository to access EAV attributes |
||
428 | * |
||
429 | * @return void |
||
430 | */ |
||
431 | public function setEavAttributeRepository(EavAttributeRepositoryInterface $eavAttributeRepository) |
||
435 | |||
436 | /** |
||
437 | * Return's the repository to access EAV attributes. |
||
438 | * |
||
439 | * @return \TechDivision\Import\Repositories\EavAttributeRepositoryInterface The repository instance |
||
440 | */ |
||
441 | public function getEavAttributeRepository() |
||
445 | |||
446 | /** |
||
447 | * Set's the repository to access EAV entity types. |
||
448 | * |
||
449 | * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface $eavEntityTypeRepository The repository to access EAV entity types |
||
450 | * |
||
451 | * @return void |
||
452 | */ |
||
453 | public function setEavEntityTypeRepository(EavEntityTypeRepositoryInterface $eavEntityTypeRepository) |
||
457 | |||
458 | /** |
||
459 | * Return's the repository to access EAV entity types. |
||
460 | * |
||
461 | * @return \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface The repository instance |
||
462 | */ |
||
463 | public function getEavEntityTypeRepository() |
||
467 | |||
468 | /** |
||
469 | * Set's the action with the product CRUD methods. |
||
470 | * |
||
471 | * @param ActionInterface $productAction The action with the product CRUD methods |
||
472 | * |
||
473 | * @return void |
||
474 | */ |
||
475 | public function setProductAction(ActionInterface $productAction) |
||
479 | |||
480 | /** |
||
481 | * Return's the action with the product CRUD methods. |
||
482 | * |
||
483 | * @return ActionInterface The action instance |
||
484 | */ |
||
485 | public function getProductAction() |
||
489 | |||
490 | /** |
||
491 | * Set's the action with the product varchar attribute CRUD methods. |
||
492 | * |
||
493 | * @param ActionInterface $productVarcharAction The action with the product varchar attriute CRUD methods |
||
494 | * |
||
495 | * @return void |
||
496 | */ |
||
497 | public function setProductVarcharAction(ActionInterface $productVarcharAction) |
||
501 | |||
502 | /** |
||
503 | * Return's the action with the product varchar attribute CRUD methods. |
||
504 | * |
||
505 | * @return ActionInterface The action instance |
||
506 | */ |
||
507 | public function getProductVarcharAction() |
||
511 | |||
512 | /** |
||
513 | * Set's the action with the product text attribute CRUD methods. |
||
514 | * |
||
515 | * @param ActionInterface $productTextAction The action with the product text attriute CRUD methods |
||
516 | * |
||
517 | * @return void |
||
518 | */ |
||
519 | public function setProductTextAction(ActionInterface $productTextAction) |
||
523 | |||
524 | /** |
||
525 | * Return's the action with the product text attribute CRUD methods. |
||
526 | * |
||
527 | * @return ActionInterface The action instance |
||
528 | */ |
||
529 | public function getProductTextAction() |
||
533 | |||
534 | /** |
||
535 | * Set's the action with the product int attribute CRUD methods. |
||
536 | * |
||
537 | * @param ActionInterface $productIntAction The action with the product int attriute CRUD methods |
||
538 | * |
||
539 | * @return void |
||
540 | */ |
||
541 | public function setProductIntAction(ActionInterface $productIntAction) |
||
545 | |||
546 | /** |
||
547 | * Return's the action with the product int attribute CRUD methods. |
||
548 | * |
||
549 | * @return ActionInterface The action instance |
||
550 | */ |
||
551 | public function getProductIntAction() |
||
555 | |||
556 | /** |
||
557 | * Set's the action with the product decimal attribute CRUD methods. |
||
558 | * |
||
559 | * @param ActionInterface $productDecimalAction The action with the product decimal attriute CRUD methods |
||
560 | * |
||
561 | * @return void |
||
562 | */ |
||
563 | public function setProductDecimalAction(ActionInterface $productDecimalAction) |
||
567 | |||
568 | /** |
||
569 | * Return's the action with the product decimal attribute CRUD methods. |
||
570 | * |
||
571 | * @return ActionInterface The action instance |
||
572 | */ |
||
573 | public function getProductDecimalAction() |
||
577 | |||
578 | /** |
||
579 | * Set's the action with the product datetime attribute CRUD methods. |
||
580 | * |
||
581 | * @param ActionInterface $productDatetimeAction The action with the product datetime attriute CRUD methods |
||
582 | * |
||
583 | * @return void |
||
584 | */ |
||
585 | public function setProductDatetimeAction(ActionInterface $productDatetimeAction) |
||
589 | |||
590 | /** |
||
591 | * Return's the action with the product datetime attribute CRUD methods. |
||
592 | * |
||
593 | * @return ActionInterface The action instance |
||
594 | */ |
||
595 | public function getProductDatetimeAction() |
||
599 | |||
600 | /** |
||
601 | * Set's the action with the product website CRUD methods. |
||
602 | * |
||
603 | * @param ActionInterface $productWebsiteAction The action with the product website CRUD methods |
||
604 | * |
||
605 | * @return void |
||
606 | */ |
||
607 | public function setProductWebsiteAction(ActionInterface $productWebsiteAction) |
||
611 | |||
612 | /** |
||
613 | * Return's the action with the product website CRUD methods. |
||
614 | * |
||
615 | * @return ActionInterface The action instance |
||
616 | */ |
||
617 | public function getProductWebsiteAction() |
||
621 | |||
622 | /** |
||
623 | * Set's the action with the category product relation CRUD methods. |
||
624 | * |
||
625 | * @param ActionInterface $categoryProductAction The action with the category product relation CRUD methods |
||
626 | * |
||
627 | * @return void |
||
628 | */ |
||
629 | public function setCategoryProductAction(ActionInterface $categoryProductAction) |
||
633 | |||
634 | /** |
||
635 | * Return's the action with the category product relation CRUD methods. |
||
636 | * |
||
637 | * @return ActionInterface The action instance |
||
638 | */ |
||
639 | public function getCategoryProductAction() |
||
643 | |||
644 | /** |
||
645 | * Set's the action with the stock item CRUD methods. |
||
646 | * |
||
647 | * @param ActionInterface $stockItemAction The action with the stock item CRUD methods |
||
648 | * |
||
649 | * @return void |
||
650 | */ |
||
651 | public function setStockItemAction(ActionInterface $stockItemAction) |
||
655 | |||
656 | /** |
||
657 | * Return's the action with the stock item CRUD methods. |
||
658 | * |
||
659 | * @return ActionInterface The action instance |
||
660 | */ |
||
661 | public function getStockItemAction() |
||
665 | |||
666 | /** |
||
667 | * Set's the action with the URL rewrite CRUD methods. |
||
668 | * |
||
669 | * @param \TechDivision\Import\Dbal\Actions\ActionInterface $urlRewriteAction The action with the URL rewrite CRUD methods |
||
670 | * |
||
671 | * @return void |
||
672 | */ |
||
673 | public function setUrlRewriteAction(ActionInterface $urlRewriteAction) |
||
677 | |||
678 | /** |
||
679 | * Return's the action with the URL rewrite CRUD methods. |
||
680 | * |
||
681 | * @return \TechDivision\Import\Dbal\Actions\ActionInterface The action instance |
||
682 | */ |
||
683 | public function getUrlRewriteAction() |
||
687 | |||
688 | /** |
||
689 | * Set's the repository to load the products with. |
||
690 | * |
||
691 | * @param \TechDivision\Import\Product\Repositories\ProductRepositoryInterface $productRepository The repository instance |
||
692 | * |
||
693 | * @return void |
||
694 | */ |
||
695 | public function setProductRepository(ProductRepositoryInterface $productRepository) |
||
699 | |||
700 | /** |
||
701 | * Return's the repository to load the products with. |
||
702 | * |
||
703 | * @return \TechDivision\Import\Product\Repositories\ProductRepositoryInterface The repository instance |
||
704 | */ |
||
705 | public function getProductRepository() |
||
709 | |||
710 | /** |
||
711 | * Set's the repository to load the product website relations with. |
||
712 | * |
||
713 | * @param \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface $productWebsiteRepository The repository instance |
||
714 | * |
||
715 | * @return void |
||
716 | */ |
||
717 | public function setProductWebsiteRepository(ProductWebsiteRepositoryInterface $productWebsiteRepository) |
||
721 | |||
722 | /** |
||
723 | * Return's the repository to load the product website relations with. |
||
724 | * |
||
725 | * @return \TechDivision\Import\Product\Repositories\ProductWebsiteRepositoryInterface The repository instance |
||
726 | */ |
||
727 | public function getProductWebsiteRepository() |
||
731 | |||
732 | /** |
||
733 | * Set's the repository to load the product datetime attribute with. |
||
734 | * |
||
735 | * @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface $productDatetimeRepository The repository instance |
||
736 | * |
||
737 | * @return void |
||
738 | */ |
||
739 | public function setProductDatetimeRepository(ProductDatetimeRepositoryInterface $productDatetimeRepository) |
||
743 | |||
744 | /** |
||
745 | * Return's the repository to load the product datetime attribute with. |
||
746 | * |
||
747 | * @return \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface The repository instance |
||
748 | */ |
||
749 | public function getProductDatetimeRepository() |
||
753 | |||
754 | /** |
||
755 | * Set's the repository to load the product decimal attribute with. |
||
756 | * |
||
757 | * @param \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface $productDecimalRepository The repository instance |
||
758 | * |
||
759 | * @return void |
||
760 | */ |
||
761 | public function setProductDecimalRepository(ProductDecimalRepositoryInterface $productDecimalRepository) |
||
765 | |||
766 | /** |
||
767 | * Return's the repository to load the product decimal attribute with. |
||
768 | * |
||
769 | * @return \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface The repository instance |
||
770 | */ |
||
771 | public function getProductDecimalRepository() |
||
775 | |||
776 | /** |
||
777 | * Set's the repository to load the product integer attribute with. |
||
778 | * |
||
779 | * @param \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface $productIntRepository The repository instance |
||
780 | * |
||
781 | * @return void |
||
782 | */ |
||
783 | public function setProductIntRepository(ProductIntRepositoryInterface $productIntRepository) |
||
787 | |||
788 | /** |
||
789 | * Return's the repository to load the product integer attribute with. |
||
790 | * |
||
791 | * @return \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface The repository instance |
||
792 | */ |
||
793 | public function getProductIntRepository() |
||
797 | |||
798 | /** |
||
799 | * Set's the repository to load the product text attribute with. |
||
800 | * |
||
801 | * @param \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface $productTextRepository The repository instance |
||
802 | * |
||
803 | * @return void |
||
804 | */ |
||
805 | public function setProductTextRepository(ProductTextRepositoryInterface $productTextRepository) |
||
809 | |||
810 | /** |
||
811 | * Return's the repository to load the product text attribute with. |
||
812 | * |
||
813 | * @return \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface The repository instance |
||
814 | */ |
||
815 | public function getProductTextRepository() |
||
819 | |||
820 | /** |
||
821 | * Set's the repository to load the product varchar attribute with. |
||
822 | * |
||
823 | * @param \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface $productVarcharRepository The repository instance |
||
824 | * |
||
825 | * @return void |
||
826 | */ |
||
827 | public function setProductVarcharRepository(ProductVarcharRepositoryInterface $productVarcharRepository) |
||
831 | |||
832 | /** |
||
833 | * Return's the repository to load the product varchar attribute with. |
||
834 | * |
||
835 | * @return \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface The repository instance |
||
836 | */ |
||
837 | public function getProductVarcharRepository() |
||
841 | |||
842 | /** |
||
843 | * Set's the repository to load the category product relations with. |
||
844 | * |
||
845 | * @param \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface $categoryProductRepository The repository instance |
||
846 | * |
||
847 | * @return void |
||
848 | */ |
||
849 | public function setCategoryProductRepository(CategoryProductRepositoryInterface $categoryProductRepository) |
||
853 | |||
854 | /** |
||
855 | * Return's the repository to load the category product relations with. |
||
856 | * |
||
857 | * @return \TechDivision\Import\Product\Repositories\CategoryProductRepositoryInterface The repository instance |
||
858 | */ |
||
859 | public function getCategoryProductRepository() |
||
863 | |||
864 | /** |
||
865 | * Set's the repository to load the stock items with. |
||
866 | * |
||
867 | * @param \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface $stockItemRepository The repository instance |
||
868 | * |
||
869 | * @return void |
||
870 | */ |
||
871 | public function setStockItemRepository(StockItemRepositoryInterface $stockItemRepository) |
||
875 | |||
876 | /** |
||
877 | * Return's the repository to load the stock items with. |
||
878 | * |
||
879 | * @return \TechDivision\Import\Product\Repositories\StockItemRepositoryInterface The repository instance |
||
880 | */ |
||
881 | public function getStockItemRepository() |
||
885 | |||
886 | /** |
||
887 | * Set's the assembler to load the product attributes with. |
||
888 | * |
||
889 | * @param \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface $productAttributeAssembler The assembler instance |
||
890 | * |
||
891 | * @return void |
||
892 | */ |
||
893 | public function setProductAttributeAssembler(ProductAttributeAssemblerInterface $productAttributeAssembler) |
||
897 | |||
898 | /** |
||
899 | * Return's the assembler to load the product attributes with. |
||
900 | * |
||
901 | * @return \TechDivision\Import\Product\Assemblers\ProductAttributeAssemblerInterface The assembler instance |
||
902 | */ |
||
903 | public function getProductAttributeAssembler() |
||
907 | |||
908 | /** |
||
909 | * Set's the repository to load the URL rewrites with. |
||
910 | * |
||
911 | * @param \TechDivision\Import\Repositories\UrlRewriteRepositoryInterface $urlRewriteRepository The repository instance |
||
912 | * |
||
913 | * @return void |
||
914 | */ |
||
915 | public function setUrlRewriteRepository(UrlRewriteRepositoryInterface $urlRewriteRepository) |
||
919 | |||
920 | /** |
||
921 | * Return's the repository to load the URL rewrites with. |
||
922 | * |
||
923 | * @return \TechDivision\Import\Repositories\UrlRewriteRepositoryInterface The repository instance |
||
924 | */ |
||
925 | public function getUrlRewriteRepository() |
||
929 | |||
930 | /** |
||
931 | * Return's an array with the available EAV attributes for the passed is user defined flag. |
||
932 | * |
||
933 | * @param integer $isUserDefined The flag itself |
||
934 | * |
||
935 | * @return array The array with the EAV attributes matching the passed flag |
||
936 | */ |
||
937 | public function getEavAttributeByIsUserDefined($isUserDefined = 1) |
||
941 | |||
942 | /** |
||
943 | * Return's the category product relations for the product with the passed SKU. |
||
944 | * |
||
945 | * @param string $sku The product SKU to load the category relations for |
||
946 | * |
||
947 | * @return array The category product relations for the product with the passed SKU |
||
948 | */ |
||
949 | public function getCategoryProductsBySku($sku) |
||
953 | |||
954 | /** |
||
955 | * Intializes the existing attributes for the entity with the passed primary key. |
||
956 | * |
||
957 | * @param string $pk The primary key of the entity to load the attributes for |
||
958 | * @param integer $storeId The ID of the store view to load the attributes for |
||
959 | * |
||
960 | * @return array The entity attributes |
||
961 | */ |
||
962 | public function getProductAttributesByPrimaryKeyAndStoreId($pk, $storeId) |
||
966 | |||
967 | /** |
||
968 | * Load's and return's a raw entity without primary key but the mandatory members only and nulled values. |
||
969 | * |
||
970 | * @param string $entityTypeCode The entity type code to return the raw entity for |
||
971 | * @param array $data An array with data that will be used to initialize the raw entity with |
||
972 | * |
||
973 | * @return array The initialized entity |
||
974 | */ |
||
975 | public function loadRawEntity($entityTypeCode, array $data = array()) |
||
979 | |||
980 | /** |
||
981 | * Load's and return's the EAV attribute option value with the passed entity type ID, code, store ID and value. |
||
982 | * |
||
983 | * @param string $entityTypeId The entity type ID of the EAV attribute to load the option value for |
||
984 | * @param string $attributeCode The code of the EAV attribute option to load |
||
985 | * @param integer $storeId The store ID of the attribute option to load |
||
986 | * @param string $value The value of the attribute option to load |
||
987 | * |
||
988 | * @return array The EAV attribute option value |
||
989 | */ |
||
990 | public function loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value) |
||
994 | |||
995 | /** |
||
996 | * Load's and return's the available products. |
||
997 | * |
||
998 | * @return array The available products |
||
999 | */ |
||
1000 | public function loadProducts() |
||
1004 | |||
1005 | /** |
||
1006 | * Load's and return's the product with the passed SKU. |
||
1007 | * |
||
1008 | * @param string $sku The SKU of the product to load |
||
1009 | * |
||
1010 | * @return array The product |
||
1011 | */ |
||
1012 | public function loadProduct($sku) |
||
1016 | |||
1017 | /** |
||
1018 | * Load's and return's the product website relation with the passed product and website ID. |
||
1019 | * |
||
1020 | * @param string $productId The product ID of the relation |
||
1021 | * @param string $websiteId The website ID of the relation |
||
1022 | * |
||
1023 | * @return array The product website |
||
1024 | */ |
||
1025 | public function loadProductWebsite($productId, $websiteId) |
||
1029 | |||
1030 | /** |
||
1031 | * Load's and return's the product website relations for the product with the passed SKU. |
||
1032 | * |
||
1033 | * @param string $sku The SKU to of the product to load the product website relations for |
||
1034 | * |
||
1035 | * @return array The product website relations |
||
1036 | */ |
||
1037 | public function loadProductWebsitesBySku($sku) |
||
1041 | |||
1042 | /** |
||
1043 | * Return's the category product relation with the passed category/product ID. |
||
1044 | * |
||
1045 | * @param integer $categoryId The category ID of the category product relation to return |
||
1046 | * @param integer $productId The product ID of the category product relation to return |
||
1047 | * |
||
1048 | * @return array The category product relation |
||
1049 | */ |
||
1050 | public function loadCategoryProduct($categoryId, $productId) |
||
1054 | |||
1055 | /** |
||
1056 | * Load's and return's the stock status with the passed product/website/stock ID. |
||
1057 | * |
||
1058 | * @param integer $productId The product ID of the stock item to load |
||
1059 | * @param integer $websiteId The website ID of the stock item to load |
||
1060 | * @param integer $stockId The stock ID of the stock item to load |
||
1061 | * |
||
1062 | * @return array The stock item |
||
1063 | */ |
||
1064 | public function loadStockItem($productId, $websiteId, $stockId) |
||
1068 | |||
1069 | /** |
||
1070 | * Load's and return's the varchar attribute with the passed params. |
||
1071 | * |
||
1072 | * @param integer $attributeCode The attribute code of the varchar attribute |
||
1073 | * @param integer $entityTypeId The entity type ID of the varchar attribute |
||
1074 | * @param integer $storeId The store ID of the varchar attribute |
||
1075 | * @param string $value The value of the varchar attribute |
||
1076 | * |
||
1077 | * @return array|null The varchar attribute |
||
1078 | */ |
||
1079 | public function loadVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue($attributeCode, $entityTypeId, $storeId, $value) |
||
1083 | |||
1084 | /** |
||
1085 | * Load's and return's the varchar attribute with the passed params. |
||
1086 | * |
||
1087 | * @param integer $attributeCode The attribute code of the varchar attribute |
||
1088 | * @param integer $entityTypeId The entity type ID of the varchar attribute |
||
1089 | * @param integer $storeId The store ID of the varchar attribute |
||
1090 | * @param string $primaryKey The primary key of the product |
||
1091 | * |
||
1092 | * @return array|null The varchar attribute |
||
1093 | */ |
||
1094 | public function loadVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndPrimaryKey($attributeCode, $entityTypeId, $storeId, $primaryKey) |
||
1098 | |||
1099 | /** |
||
1100 | * Load's and return's the varchar attribute with the passed params. |
||
1101 | * |
||
1102 | * @param integer $attributeCode The attribute code of the varchar attribute |
||
1103 | * @param integer $entityTypeId The entity type ID of the varchar attribute |
||
1104 | * @param integer $storeId The store ID of the varchar attribute |
||
1105 | * @param string $value The value of the varchar attribute |
||
1106 | * |
||
1107 | * @return array|null The varchar attribute |
||
1108 | */ |
||
1109 | public function loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue($attributeCode, $entityTypeId, $storeId, $value) |
||
1113 | |||
1114 | /** |
||
1115 | * Load's and return's the varchar attribute with the passed params. |
||
1116 | * |
||
1117 | * @param integer $attributeCode The attribute code of the varchar attribute |
||
1118 | * @param integer $entityTypeId The entity type ID of the varchar attribute |
||
1119 | * @param integer $storeId The store ID of the varchar attribute |
||
1120 | * @param string $pk The primary key of the product |
||
1121 | * |
||
1122 | * @return array|null The varchar attribute |
||
1123 | */ |
||
1124 | public function loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndPK($attributeCode, $entityTypeId, $storeId, $pk) |
||
1128 | |||
1129 | /** |
||
1130 | * Return's an EAV entity type with the passed entity type code. |
||
1131 | * |
||
1132 | * @param string $entityTypeCode The code of the entity type to return |
||
1133 | * |
||
1134 | * @return array The entity type with the passed entity type code |
||
1135 | */ |
||
1136 | public function loadEavEntityTypeByEntityTypeCode($entityTypeCode) |
||
1140 | |||
1141 | /** |
||
1142 | * Load's and return's the URL rewrite for the given request path and store ID |
||
1143 | * |
||
1144 | * @param string $requestPath The request path to load the URL rewrite for |
||
1145 | * @param int $storeId The store ID to load the URL rewrite for |
||
1146 | * |
||
1147 | * @return array|null The URL rewrite found for the given request path and store ID |
||
1148 | */ |
||
1149 | public function loadUrlRewriteByRequestPathAndStoreId(string $requestPath, int $storeId) |
||
1153 | |||
1154 | /** |
||
1155 | * Persist's the passed product data and return's the ID. |
||
1156 | * |
||
1157 | * @param array $product The product data to persist |
||
1158 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1159 | * |
||
1160 | * @return string The ID of the persisted entity |
||
1161 | */ |
||
1162 | public function persistProduct($product, $name = null) |
||
1166 | |||
1167 | /** |
||
1168 | * Persist's the passed product varchar attribute. |
||
1169 | * |
||
1170 | * @param array $attribute The attribute to persist |
||
1171 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1172 | * |
||
1173 | * @return string The ID of the persisted attribute |
||
1174 | */ |
||
1175 | public function persistProductVarcharAttribute($attribute, $name = null) |
||
1179 | |||
1180 | /** |
||
1181 | * Persist's the passed product integer attribute. |
||
1182 | * |
||
1183 | * @param array $attribute The attribute to persist |
||
1184 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1185 | * |
||
1186 | * @return void |
||
1187 | */ |
||
1188 | public function persistProductIntAttribute($attribute, $name = null) |
||
1192 | |||
1193 | /** |
||
1194 | * Persist's the passed product decimal attribute. |
||
1195 | * |
||
1196 | * @param array $attribute The attribute to persist |
||
1197 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1198 | * |
||
1199 | * @return void |
||
1200 | */ |
||
1201 | public function persistProductDecimalAttribute($attribute, $name = null) |
||
1205 | |||
1206 | /** |
||
1207 | * Persist's the passed product datetime attribute. |
||
1208 | * |
||
1209 | * @param array $attribute The attribute to persist |
||
1210 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1211 | * |
||
1212 | * @return void |
||
1213 | */ |
||
1214 | public function persistProductDatetimeAttribute($attribute, $name = null) |
||
1218 | |||
1219 | /** |
||
1220 | * Persist's the passed product text attribute. |
||
1221 | * |
||
1222 | * @param array $attribute The attribute to persist |
||
1223 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1224 | * |
||
1225 | * @return void |
||
1226 | */ |
||
1227 | public function persistProductTextAttribute($attribute, $name = null) |
||
1231 | |||
1232 | /** |
||
1233 | * Persist's the passed product website data and return's the ID. |
||
1234 | * |
||
1235 | * @param array $productWebsite The product website data to persist |
||
1236 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1237 | * |
||
1238 | * @return void |
||
1239 | */ |
||
1240 | public function persistProductWebsite($productWebsite, $name = null) |
||
1244 | |||
1245 | /** |
||
1246 | * Persist's the passed category product relation. |
||
1247 | * |
||
1248 | * @param array $categoryProduct The category product relation to persist |
||
1249 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1250 | * |
||
1251 | * @return void |
||
1252 | */ |
||
1253 | public function persistCategoryProduct($categoryProduct, $name = null) |
||
1257 | |||
1258 | /** |
||
1259 | * Persist's the passed stock item data and return's the ID. |
||
1260 | * |
||
1261 | * @param array $stockItem The stock item data to persist |
||
1262 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1263 | * |
||
1264 | * @return void |
||
1265 | */ |
||
1266 | public function persistStockItem($stockItem, $name = null) |
||
1270 | |||
1271 | /** |
||
1272 | * Persist's the URL rewrite with the passed data. |
||
1273 | * |
||
1274 | * @param array $row The URL rewrite to persist |
||
1275 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1276 | * |
||
1277 | * @return string The ID of the persisted entity |
||
1278 | */ |
||
1279 | public function persistUrlRewrite($row, $name = null) |
||
1283 | |||
1284 | /** |
||
1285 | * Delete's the entity with the passed attributes. |
||
1286 | * |
||
1287 | * @param array $row The attributes of the entity to delete |
||
1288 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1289 | * |
||
1290 | * @return void |
||
1291 | */ |
||
1292 | public function deleteProduct($row, $name = null) |
||
1296 | |||
1297 | /** |
||
1298 | * Delete's the URL rewrite with the passed attributes. |
||
1299 | * |
||
1300 | * @param array $row The attributes of the entity to delete |
||
1301 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1302 | * |
||
1303 | * @return void |
||
1304 | */ |
||
1305 | public function deleteUrlRewrite($row, $name = null) |
||
1309 | |||
1310 | /** |
||
1311 | * Delete's the stock item(s) with the passed attributes. |
||
1312 | * |
||
1313 | * @param array $row The attributes of the entity to delete |
||
1314 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1315 | * |
||
1316 | * @return void |
||
1317 | */ |
||
1318 | public function deleteStockItem($row, $name = null) |
||
1322 | |||
1323 | /** |
||
1324 | * Delete's the product website relations with the passed attributes. |
||
1325 | * |
||
1326 | * @param array $row The attributes of the entity to delete |
||
1327 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1328 | * |
||
1329 | * @return void |
||
1330 | */ |
||
1331 | public function deleteProductWebsite($row, $name = null) |
||
1335 | |||
1336 | /** |
||
1337 | * Delete's the category product relations with the passed attributes. |
||
1338 | * |
||
1339 | * @param array $row The attributes of the entity to delete |
||
1340 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1341 | * |
||
1342 | * @return void |
||
1343 | */ |
||
1344 | public function deleteCategoryProduct($row, $name = null) |
||
1348 | |||
1349 | /** |
||
1350 | * Delete's the product datetime attribute with the passed attributes. |
||
1351 | * |
||
1352 | * @param array $row The attributes of the entity to delete |
||
1353 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1354 | * |
||
1355 | * @return void |
||
1356 | */ |
||
1357 | public function deleteProductDatetimeAttribute($row, $name = null) |
||
1361 | |||
1362 | /** |
||
1363 | * Delete's the product decimal attribute with the passed attributes. |
||
1364 | * |
||
1365 | * @param array $row The attributes of the entity to delete |
||
1366 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1367 | * |
||
1368 | * @return void |
||
1369 | */ |
||
1370 | public function deleteProductDecimalAttribute($row, $name = null) |
||
1374 | |||
1375 | /** |
||
1376 | * Delete's the product integer attribute with the passed attributes. |
||
1377 | * |
||
1378 | * @param array $row The attributes of the entity to delete |
||
1379 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1380 | * |
||
1381 | * @return void |
||
1382 | */ |
||
1383 | public function deleteProductIntAttribute($row, $name = null) |
||
1387 | |||
1388 | /** |
||
1389 | * Delete's the product text attribute with the passed attributes. |
||
1390 | * |
||
1391 | * @param array $row The attributes of the entity to delete |
||
1392 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1393 | * |
||
1394 | * @return void |
||
1395 | */ |
||
1396 | public function deleteProductTextAttribute($row, $name = null) |
||
1400 | |||
1401 | /** |
||
1402 | * Delete's the product varchar attribute with the passed attributes. |
||
1403 | * |
||
1404 | * @param array $row The attributes of the entity to delete |
||
1405 | * @param string|null $name The name of the prepared statement that has to be executed |
||
1406 | * |
||
1407 | * @return void |
||
1408 | */ |
||
1409 | public function deleteProductVarcharAttribute($row, $name = null) |
||
1413 | |||
1414 | /** |
||
1415 | * Clean-Up the repositories to free memory. |
||
1416 | * |
||
1417 | * @return void |
||
1418 | */ |
||
1419 | public function cleanUp() |
||
1422 | } |
||
1423 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: