Completed
Push — master ( 2a9d12...a3be75 )
by Tim
15s
created

ImportProcessor::getEavAttributeGroupRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Services\ImportProcessor
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Services;
22
23
use TechDivision\Import\Utils\RegistryKeys;
24
use TechDivision\Import\Utils\MemberNames;
25
use TechDivision\Import\Connection\ConnectionInterface;
26
use TechDivision\Import\Assembler\CategoryAssembler;
27
use TechDivision\Import\Actions\StoreAction;
28
use TechDivision\Import\Actions\StoreGroupAction;
29
use TechDivision\Import\Actions\StoreWebsiteAction;
30
use TechDivision\Import\Repositories\CategoryRepository;
31
use TechDivision\Import\Repositories\CategoryVarcharRepository;
32
use TechDivision\Import\Repositories\EavAttributeRepository;
33
use TechDivision\Import\Repositories\EavAttributeSetRepository;
34
use TechDivision\Import\Repositories\EavAttributeGroupRepository;
35
use TechDivision\Import\Repositories\EavEntityTypeRepository;
36
use TechDivision\Import\Repositories\StoreRepository;
37
use TechDivision\Import\Repositories\StoreWebsiteRepository;
38
use TechDivision\Import\Repositories\TaxClassRepository;
39
use TechDivision\Import\Repositories\LinkTypeRepository;
40
use TechDivision\Import\Repositories\LinkAttributeRepository;
41
use TechDivision\Import\Repositories\CoreConfigDataRepository;
42
43
/**
44
 * Processor implementation to load global data.
45
 *
46
 * @author    Tim Wagner <[email protected]>
47
 * @copyright 2016 TechDivision GmbH <[email protected]>
48
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
49
 * @link      https://github.com/techdivision/import
50
 * @link      http://www.techdivision.com
51
 */
52
class ImportProcessor implements ImportProcessorInterface
53
{
54
55
    /**
56
     * A connection to use.
57
     *
58
     * @var \TechDivision\Import\Connection\ConnectionInterface
59
     */
60
    protected $connection;
61
62
    /**
63
     * The category assembler instance.
64
     *
65
     * @var \TechDivision\Import\Assembler\CategoryAssembler
66
     */
67
    protected $categoryAssembler;
68
69
    /**
70
     * The repository to access categories.
71
     *
72
     * @var \TechDivision\Import\Repositories\CategoryRepository
73
     */
74
    protected $categoryRepository;
75
76
    /**
77
     * The repository to access category varchar values.
78
     *
79
     * @var \TechDivision\Import\Repositories\CategoryVarcharRepository
80
     */
81
    protected $categoryVarcharRepository;
82
83
    /**
84
     * The repository to access EAV attributes.
85
     *
86
     * @var \TechDivision\Import\Repositories\EavAttributeRepository
87
     */
88
    protected $eavAttributeRepository;
89
90
    /**
91
     * The repository to access EAV attribute sets.
92
     *
93
     * @var \TechDivision\Import\Repositories\EavAttributeSetRepository
94
     */
95
    protected $eavAttributeSetRepository;
96
97
    /**
98
     * The repository to access EAV attribute groups.
99
     *
100
     * @var \TechDivision\Import\Repositories\EavAttributeGroupRepository
101
     */
102
    protected $eavAttributeGroupRepository;
103
104
    /**
105
     * The repository to access EAV entity types.
106
     *
107
     * @var \TechDivision\Import\Repositories\EavEntityTypeRepository
108
     */
109
    protected $eavEntityTypeRepository;
110
111
    /**
112
     * The repository to access stores.
113
     *
114
     * @var \TechDivision\Import\Repositories\StoreRepository
115
     */
116
    protected $storeRepository;
117
118
    /**
119
     * The repository to access store websites.
120
     *
121
     * @var \TechDivision\Import\Repositories\StoreWebsiteRepository
122
     */
123
    protected $storeWebsiteRepository;
124
125
    /**
126
     * The repository to access tax classes.
127
     *
128
     * @var \TechDivision\Import\Repositories\TaxClassRepository
129
     */
130
    protected $taxClassRepository;
131
132
    /**
133
     * The repository to access link types.
134
     *
135
     * @var \TechDivision\Import\Repositories\LinkTypeRepository
136
     */
137
    protected $linkTypeRepository;
138
139
    /**
140
     * The repository to access link attributes.
141
     *
142
     * @var \TechDivision\Import\Repositories\LinkAttributeRepository
143
     */
144
    protected $linkAttributeRepository;
145
146
    /**
147
     * The repository to access the configuration.
148
     *
149
     * @var \TechDivision\Import\Repositories\CoreConfigDataRepository
150
     */
151
    protected $coreConfigDataRepository;
152
153
    /**
154
     * The action for store CRUD methods.
155
     *
156
     * @var \TechDivision\Import\Actions\StoreAction
157
     */
158
    protected $storeAction;
159
160
    /**
161
     * The action for store group CRUD methods.
162
     *
163
     * @var \TechDivision\Import\Actions\StoreGroupAction
164
     */
165
    protected $storeGroupAction;
166
167
    /**
168
     * The action for store website CRUD methods.
169
     *
170
     * @var \TechDivision\Import\Actions\StoreWebsiteAction
171
     */
172
    protected $storeWebsiteAction;
173
174
    /**
175
     * Initialize the processor with the necessary assembler and repository instances.
176
     *
177
     * @param \TechDivision\Import\Connection\ConnectionInterface           $connection                  The connection to use
178
     * @param \TechDivision\Import\Assembler\CategoryAssembler              $categoryAssembler           The category assembler instance
179
     * @param \TechDivision\Import\Repositories\CategoryRepository          $categoryRepository          The repository to access categories
180
     * @param \TechDivision\Import\Repositories\CategoryVarcharRepository   $categoryVarcharRepository   The repository to access category varchar values
181
     * @param \TechDivision\Import\Repositories\EavAttributeRepository      $eavAttributeRepository      The repository to access EAV attributes
182
     * @param \TechDivision\Import\Repositories\EavAttributeSetRepository   $eavAttributeSetRepository   The repository to access EAV attribute sets
183
     * @param \TechDivision\Import\Repositories\EavAttributeGroupRepository $eavAttributeGroupRepository The repository to access EAV attribute groups
184
     * @param \TechDivision\Import\Repositories\EavEntityTypeRepository     $eavEntityTypeRepository     The repository to access EAV entity types
185
     * @param \TechDivision\Import\Repositories\StoreRepository             $storeRepository             The repository to access stores
186
     * @param \TechDivision\Import\Repositories\StoreWebsiteRepository      $storeWebsiteRepository      The repository to access store websites
187
     * @param \TechDivision\Import\Repositories\TaxClassRepository          $taxClassRepository          The repository to access tax classes
188
     * @param \TechDivision\Import\Repositories\LinkTypeRepository          $linkTypeRepository          The repository to access link types
189
     * @param \TechDivision\Import\Repositories\LinkAttributeRepository     $linkAttributeRepository     The repository to access link attributes
190
     * @param \TechDivision\Import\Repositories\CoreConfigDataRepository    $coreConfigDataRepository    The repository to access the configuration
191
     * @param \TechDivision\Import\Actions\StoreAction                      $storeAction                 The action with the store CRUD methods
192
     * @param \TechDivision\Import\Actions\StoreGroupAction                 $storeGroupAction            The action with the store group CRUD methods
193
     * @param \TechDivision\Import\Actions\StoreWebsiteAction               $storeWebsiteAction          The action with the store website CRUD methods
194
     */
195
    public function __construct(
196
        ConnectionInterface $connection,
197
        CategoryAssembler $categoryAssembler,
198
        CategoryRepository $categoryRepository,
199
        CategoryVarcharRepository $categoryVarcharRepository,
200
        EavAttributeRepository $eavAttributeRepository,
201
        EavAttributeSetRepository $eavAttributeSetRepository,
202
        EavAttributeGroupRepository $eavAttributeGroupRepository,
203
        EavEntityTypeRepository $eavEntityTypeRepository,
204
        StoreRepository $storeRepository,
205
        StoreWebsiteRepository $storeWebsiteRepository,
206
        TaxClassRepository $taxClassRepository,
207
        LinkTypeRepository $linkTypeRepository,
208
        LinkAttributeRepository $linkAttributeRepository,
209
        CoreConfigDataRepository $coreConfigDataRepository,
210
        StoreAction $storeAction,
211
        StoreGroupAction $storeGroupAction,
212
        StoreWebsiteAction $storeWebsiteAction
213
    ) {
214
        $this->setConnection($connection);
215
        $this->setCategoryAssembler($categoryAssembler);
216
        $this->setCategoryRepository($categoryRepository);
217
        $this->setCategoryVarcharRepository($categoryVarcharRepository);
218
        $this->setEavAttributeRepository($eavAttributeRepository);
219
        $this->setEavAttributeSetRepository($eavAttributeSetRepository);
220
        $this->setEavAttributeGroupRepository($eavAttributeGroupRepository);
221
        $this->setEavEntityTypeRepository($eavEntityTypeRepository);
222
        $this->setStoreRepository($storeRepository);
223
        $this->setStoreWebsiteRepository($storeWebsiteRepository);
224
        $this->setTaxClassRepository($taxClassRepository);
225
        $this->setLinkTypeRepository($linkTypeRepository);
226
        $this->setLinkAttributeRepository($linkAttributeRepository);
0 ignored issues
show
Documentation introduced by
$linkAttributeRepository is of type object<TechDivision\Impo...inkAttributeRepository>, but the function expects a object<TechDivision\Impo...ies\LinkTypeRepository>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
227
        $this->setCoreConfigDataRepository($coreConfigDataRepository);
228
        $this->setStoreAction($storeAction);
229
        $this->setStoreGroupAction($storeGroupAction);
230
        $this->setStoreWebsiteAction($storeWebsiteAction);
231
    }
232
233
    /**
234
     * Set's the passed connection.
235
     *
236
     * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to set
237
     *
238
     * @return void
239
     */
240
    public function setConnection(ConnectionInterface $connection)
241
    {
242
        $this->connection = $connection;
243
    }
244
245
    /**
246
     * Return's the connection.
247
     *
248
     * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance
249
     */
250
    public function getConnection()
251
    {
252
        return $this->connection;
253
    }
254
255
    /**
256
     * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO
257
     * object instance are not committed until you end the transaction by calling ProductProcessor::commit().
258
     * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection
259
     * to autocommit mode.
260
     *
261
     * @return boolean Returns TRUE on success or FALSE on failure
262
     * @link http://php.net/manual/en/pdo.begintransaction.php
263
     */
264
    public function beginTransaction()
265
    {
266
        return $this->connection->beginTransaction();
267
    }
268
269
    /**
270
     * Commits a transaction, returning the database connection to autocommit mode until the next call to
271
     * ProductProcessor::beginTransaction() starts a new transaction.
272
     *
273
     * @return boolean Returns TRUE on success or FALSE on failure
274
     * @link http://php.net/manual/en/pdo.commit.php
275
     */
276
    public function commit()
277
    {
278
        return $this->connection->commit();
279
    }
280
281
    /**
282
     * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction().
283
     *
284
     * If the database was set to autocommit mode, this function will restore autocommit mode after it has
285
     * rolled back the transaction.
286
     *
287
     * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition
288
     * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
289
     * COMMIT will prevent you from rolling back any other changes within the transaction boundary.
290
     *
291
     * @return boolean Returns TRUE on success or FALSE on failure
292
     * @link http://php.net/manual/en/pdo.rollback.php
293
     */
294
    public function rollBack()
295
    {
296
        return $this->connection->rollBack();
297
    }
298
299
    /**
300
     * Set's the category assembler.
301
     *
302
     * @param \TechDivision\Import\Assembler\CategoryAssembler $categoryAssembler The category assembler
303
     *
304
     * @return void
305
     */
306
    public function setCategoryAssembler($categoryAssembler)
307
    {
308
        $this->categoryAssembler = $categoryAssembler;
309
    }
310
311
    /**
312
     * Return's the category assembler.
313
     *
314
     * @return \TechDivision\Import\Assembler\CategoryAssembler The category assembler instance
315
     */
316
    public function getCategoryAssembler()
317
    {
318
        return $this->categoryAssembler;
319
    }
320
321
    /**
322
     * Set's the repository to access categories.
323
     *
324
     * @param \TechDivision\Import\Repositories\CategoryRepository $categoryRepository The repository to access categories
325
     *
326
     * @return void
327
     */
328
    public function setCategoryRepository($categoryRepository)
329
    {
330
        $this->categoryRepository = $categoryRepository;
331
    }
332
333
    /**
334
     * Return's the repository to access categories.
335
     *
336
     * @return \TechDivision\Import\Repositories\CategoryRepository The repository instance
337
     */
338
    public function getCategoryRepository()
339
    {
340
        return $this->categoryRepository;
341
    }
342
343
    /**
344
     * Return's the repository to access category varchar values.
345
     *
346
     * @param \TechDivision\Import\Repositories\CategoryVarcharRepository $categoryVarcharRepository The repository instance
347
     *
348
     * @return void
349
     */
350
    public function setCategoryVarcharRepository($categoryVarcharRepository)
351
    {
352
        $this->categoryVarcharRepository = $categoryVarcharRepository;
353
    }
354
355
    /**
356
     * Return's the repository to access category varchar values.
357
     *
358
     * @return \TechDivision\Import\Repositories\CategoryVarcharRepository The repository instance
359
     */
360
    public function getCategoryVarcharRepository()
361
    {
362
        return $this->categoryVarcharRepository;
363
    }
364
365
    /**
366
     * Set's the repository to access EAV attributes.
367
     *
368
     * @param \TechDivision\Import\Repositories\EavAttributeRepository $eavAttributeRepository The repository to access EAV attributes
369
     *
370
     * @return void
371
     */
372
    public function setEavAttributeRepository($eavAttributeRepository)
373
    {
374
        $this->eavAttributeRepository = $eavAttributeRepository;
375
    }
376
377
    /**
378
     * Return's the repository to access EAV attributes.
379
     *
380
     * @return \TechDivision\Import\Repositories\EavAttributeRepository The repository instance
381
     */
382
    public function getEavAttributeRepository()
383
    {
384
        return $this->eavAttributeRepository;
385
    }
386
387
    /**
388
     * Set's the repository to access EAV attribute sets.
389
     *
390
     * @param \TechDivision\Import\Repositories\EavAttributeSetRepository $eavAttributeSetRepository The repository the access EAV attribute sets
391
     *
392
     * @return void
393
     */
394
    public function setEavAttributeSetRepository($eavAttributeSetRepository)
395
    {
396
        $this->eavAttributeSetRepository = $eavAttributeSetRepository;
397
    }
398
399
    /**
400
     * Return's the repository to access EAV attribute sets.
401
     *
402
     * @return \TechDivision\Import\Repositories\EavAttributeSetRepository The repository instance
403
     */
404
    public function getEavAttributeSetRepository()
405
    {
406
        return $this->eavAttributeSetRepository;
407
    }
408
409
    /**
410
     * Set's the repository to access EAV attribute groups.
411
     *
412
     * @param \TechDivision\Import\Repositories\EavAttributeGroupRepository $eavAttributeGroupRepository The repository the access EAV attribute groups
413
     *
414
     * @return void
415
     */
416
    public function setEavAttributeGroupRepository($eavAttributeGroupRepository)
417
    {
418
        $this->eavAttributeGroupRepository = $eavAttributeGroupRepository;
419
    }
420
421
    /**
422
     * Return's the repository to access EAV attribute groups.
423
     *
424
     * @return \TechDivision\Import\Repositories\EavAttributeGroupRepository The repository instance
425
     */
426
    public function getEavAttributeGroupRepository()
427
    {
428
        return $this->eavAttributeGroupRepository;
429
    }
430
431
    /**
432
     * Return's the repository to access EAV entity types.
433
     *
434
     * @return \TechDivision\Import\Repositories\EavEntityTypeRepository The repository instance
435
     */
436
    public function getEavEntityTypeRepository()
437
    {
438
        return $this->eavEntityTypeRepository;
439
    }
440
441
    /**
442
     * Set's the repository to access EAV entity types.
443
     *
444
     * @param \TechDivision\Import\Repositories\EavEntityTypeRepository $eavEntityTypeRepository The repository the access EAV entity types
445
     *
446
     * @return void
447
     */
448
    public function setEavEntityTypeRepository($eavEntityTypeRepository)
449
    {
450
        $this->eavEntityTypeRepository = $eavEntityTypeRepository;
451
    }
452
453
    /**
454
     * Set's the repository to access stores.
455
     *
456
     * @param \TechDivision\Import\Repositories\StoreRepository $storeRepository The repository the access stores
457
     *
458
     * @return void
459
     */
460
    public function setStoreRepository($storeRepository)
461
    {
462
        $this->storeRepository = $storeRepository;
463
    }
464
465
    /**
466
     * Return's the repository to access stores.
467
     *
468
     * @return \TechDivision\Import\Repositories\StoreRepository The repository instance
469
     */
470
    public function getStoreRepository()
471
    {
472
        return $this->storeRepository;
473
    }
474
475
    /**
476
     * Set's the repository to access store websites.
477
     *
478
     * @param \TechDivision\Import\Repositories\StoreWebsiteRepository $storeWebsiteRepository The repository the access store websites
479
     *
480
     * @return void
481
     */
482
    public function setStoreWebsiteRepository($storeWebsiteRepository)
483
    {
484
        $this->storeWebsiteRepository = $storeWebsiteRepository;
485
    }
486
487
    /**
488
     * Return's the repository to access store websites.
489
     *
490
     * @return \TechDivision\Import\Repositories\StoreWebsiteRepository The repository instance
491
     */
492
    public function getStoreWebsiteRepository()
493
    {
494
        return $this->storeWebsiteRepository;
495
    }
496
497
    /**
498
     * Set's the repository to access tax classes.
499
     *
500
     * @param \TechDivision\Import\Repositories\TaxClassRepository $taxClassRepository The repository the access stores
501
     *
502
     * @return void
503
     */
504
    public function setTaxClassRepository($taxClassRepository)
505
    {
506
        $this->taxClassRepository = $taxClassRepository;
507
    }
508
509
    /**
510
     * Return's the repository to access tax classes.
511
     *
512
     * @return \TechDivision\Import\Repositories\TaxClassRepository The repository instance
513
     */
514
    public function getTaxClassRepository()
515
    {
516
        return $this->taxClassRepository;
517
    }
518
519
    /**
520
     * Set's the repository to access link types.
521
     *
522
     * @param \TechDivision\Import\Repositories\LinkTypeRepository $linkTypeRepository The repository to access link types
523
     *
524
     * @return void
525
     */
526
    public function setLinkTypeRepository($linkTypeRepository)
527
    {
528
        $this->linkTypeRepository = $linkTypeRepository;
529
    }
530
531
    /**
532
     * Return's the repository to access link types.
533
     *
534
     * @return \TechDivision\Import\Repositories\LinkTypeRepository The repository instance
535
     */
536
    public function getLinkTypeRepository()
537
    {
538
        return $this->linkTypeRepository;
539
    }
540
541
    /**
542
     * Set's the repository to access link attributes.
543
     *
544
     * @param \TechDivision\Import\Repositories\LinkTypeRepository $linkAttributeRepository The repository to access link attributes
545
     *
546
     * @return void
547
     */
548
    public function setLinkAttributeRepository($linkAttributeRepository)
549
    {
550
        $this->linkAttributeRepository = $linkAttributeRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $linkAttributeRepository of type object<TechDivision\Impo...ies\LinkTypeRepository> is incompatible with the declared type object<TechDivision\Impo...inkAttributeRepository> of property $linkAttributeRepository.

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..

Loading history...
551
    }
552
553
    /**
554
     * Return's the repository to access link attributes.
555
     *
556
     * @return \TechDivision\Import\Repositories\LinkTypeRepository The repository instance
557
     */
558
    public function getLinkAttributeRepository()
559
    {
560
        return $this->linkAttributeRepository;
561
    }
562
563
    /**
564
     * Set's the repository to access the Magento 2 configuration.
565
     *
566
     * @param \TechDivision\Import\Repositories\CoreConfigDataRepository $coreConfigDataRepository The repository to access the Magento 2 configuration
567
     *
568
     * @return void
569
     */
570
    public function setCoreConfigDataRepository($coreConfigDataRepository)
571
    {
572
        $this->coreConfigDataRepository = $coreConfigDataRepository;
573
    }
574
575
    /**
576
     * Return's the repository to access the Magento 2 configuration.
577
     *
578
     * @return \TechDivision\Import\Repositories\CoreConfigDataRepository The repository instance
579
     */
580
    public function getCoreConfigDataRepository()
581
    {
582
        return $this->coreConfigDataRepository;
583
    }
584
585
    /**
586
     * Set's the action with the store CRUD methods.
587
     *
588
     * @param \TechDivision\Import\Actions\StoreAction $storeAction The action with the store CRUD methods
589
     *
590
     * @return void
591
     */
592
    public function setStoreAction($storeAction)
593
    {
594
        $this->storeAction = $storeAction;
595
    }
596
597
    /**
598
     * Return's the action with the store CRUD methods.
599
     *
600
     * @return \TechDivision\Import\Actions\StoreAction The action instance
601
     */
602
    public function getStoreAction()
603
    {
604
        return $this->storeAction;
605
    }
606
607
    /**
608
     * Set's the action with the store group CRUD methods.
609
     *
610
     * @param \TechDivision\Import\Actions\StoreGroupAction $storeGroupAction The action with the store group CRUD methods
611
     *
612
     * @return void
613
     */
614
    public function setStoreGroupAction($storeGroupAction)
615
    {
616
        $this->storeGroupAction = $storeGroupAction;
617
    }
618
619
    /**
620
     * Return's the action with the store group CRUD methods.
621
     *
622
     * @return \TechDivision\Import\Actions\StoreGroupAction The action instance
623
     */
624
    public function getStoreGroupAction()
625
    {
626
        return $this->storeGroupAction;
627
    }
628
629
    /**
630
     * Set's the action with the store website CRUD methods.
631
     *
632
     * @param \TechDivision\Import\Actions\StoreWebsiteAction $storeWebsiteAction The action with the store website CRUD methods
633
     *
634
     * @return void
635
     */
636
    public function setStoreWebsiteAction($storeWebsiteAction)
637
    {
638
        $this->storeWebsiteAction = $storeWebsiteAction;
639
    }
640
641
    /**
642
     * Return's the action with the store website CRUD methods.
643
     *
644
     * @return \TechDivision\Import\Actions\StoreWebsiteAction The action instance
645
     */
646
    public function getStoreWebsiteAction()
647
    {
648
        return $this->storeWebsiteAction;
649
    }
650
651
    /**
652
     * Return's the EAV attribute set with the passed ID.
653
     *
654
     * @param integer $id The ID of the EAV attribute set to load
655
     *
656
     * @return array The EAV attribute set
657
     */
658
    public function getEavAttributeSet($id)
659
    {
660
        return $this->getEavAttributeSetRepository()->load($id);
661
    }
662
663
    /**
664
     * Return's the attribute sets for the passed entity type ID.
665
     *
666
     * @param mixed $entityTypeId The entity type ID to return the attribute sets for
667
     *
668
     * @return array|boolean The attribute sets for the passed entity type ID
669
     */
670
    public function getEavAttributeSetsByEntityTypeId($entityTypeId)
671
    {
672
        return $this->getEavAttributeSetRepository()->findAllByEntityTypeId($entityTypeId);
673
    }
674
675
    /**
676
     * Return's the attribute groups for the passed attribute set ID, whereas the array
677
     * is prepared with the attribute group names as keys.
678
     *
679
     * @param mixed $attributeSetId The EAV attribute set ID to return the attribute groups for
680
     *
681
     * @return array|boolean The EAV attribute groups for the passed attribute ID
682
     */
683
    public function getEavAttributeGroupsByAttributeSetId($attributeSetId)
684
    {
685
        return $this->getEavAttributeGroupRepository()->findAllByAttributeSetId($attributeSetId);
686
    }
687
688
    /**
689
     * Return's an array with the EAV attributes for the passed entity type ID and attribute set name.
690
     *
691
     * @param integer $entityTypeId     The entity type ID of the EAV attributes to return
692
     * @param string  $attributeSetName The attribute set name of the EAV attributes to return
693
     *
694
     * @return array The
695
     */
696
    public function getEavAttributesByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName)
697
    {
698
        return $this->getEavAttributeRepository()->findAllByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName);
699
    }
700
701
    /**
702
     * Return's an array with the available EAV attributes for the passed option value and store ID.
703
     *
704
     * @param string $optionValue The option value of the EAV attributes
705
     * @param string $storeId     The store ID of the EAV attribues
706
     *
707
     * @return array The array with all available EAV attributes
708
     */
709
    public function getEavAttributesByOptionValueAndStoreId($optionValue, $storeId)
710
    {
711
        return $this->getEavAttributeRepository()->findAllByOptionValueAndStoreId($optionValue, $storeId);
712
    }
713
714
    /**
715
     * Return's the first EAV attribute for the passed option value and store ID.
716
     *
717
     * @param string $optionValue The option value of the EAV attributes
718
     * @param string $storeId     The store ID of the EAV attribues
719
     *
720
     * @return array The array with the EAV attribute
721
     */
722
    public function getEavAttributeByOptionValueAndStoreId($optionValue, $storeId)
723
    {
724
        return $this->getEavAttributeRepository()->findOneByOptionValueAndStoreId($optionValue, $storeId);
725
    }
726
727
    /**
728
     * Return's an array with the available EAV attributes for the passed is user defined flag.
729
     *
730
     * @param integer $isUserDefined The flag itself
731
     *
732
     * @return array The array with the EAV attributes matching the passed flag
733
     */
734
    public function getEavAttributesByIsUserDefined($isUserDefined = 1)
735
    {
736
        return $this->getEavAttributeRepository()->findAllByIsUserDefined($isUserDefined);
737
    }
738
739
    /**
740
     * Return's an array with the available EAV attributes for the passed is entity type and
741
     * user defined flag.
742
     *
743
     * @param integer $entityTypeId  The entity type ID of the EAV attributes to return
744
     * @param integer $isUserDefined The flag itself
745
     *
746
     * @return array The array with the EAV attributes matching the passed entity type and user defined flag
747
     */
748
    public function getEavAttributesByEntityTypeIdAndIsUserDefined($entityTypeId, $isUserDefined = 1)
749
    {
750
        return $this->getEavAttributeRepository()->findAllByEntityTypeIdAndIsUserDefined($entityTypeId, $isUserDefined);
751
    }
752
753
    /**
754
     * Return's an array with all available EAV entity types with the entity type code as key.
755
     *
756
     * @return array The available link types
757
     */
758
    public function getEavEntityTypes()
759
    {
760
        return $this->getEavEntityTypeRepository()->findAll();
761
    }
762
763
    /**
764
     * Return's an array with the available stores.
765
     *
766
     * @return array The array with the available stores
767
     */
768
    public function getStores()
769
    {
770
        return $this->getStoreRepository()->findAll();
771
    }
772
773
    /**
774
     * Return's the default store.
775
     *
776
     * @return array The default store
777
     */
778
    public function getDefaultStore()
779
    {
780
        return $this->getStoreRepository()->findOneByDefault();
781
    }
782
783
    /**
784
     * Return's an array with the available store websites.
785
     *
786
     * @return array The array with the available store websites
787
     */
788
    public function getStoreWebsites()
789
    {
790
        return $this->getStoreWebsiteRepository()->findAll();
791
    }
792
793
    /**
794
     * Return's an array with the available tax classes.
795
     *
796
     * @return array The array with the available tax classes
797
     */
798
    public function getTaxClasses()
799
    {
800
        return $this->getTaxClassRepository()->findAll();
801
    }
802
803
    /**
804
     * Return's an array with all available categories.
805
     *
806
     * @return array The available categories
807
     */
808
    public function getCategories()
809
    {
810
        return $this->getCategoryRepository()->findAll();
811
    }
812
813
    /**
814
     * Return's an array with the root categories with the store code as key.
815
     *
816
     * @return array The root categories
817
     */
818
    public function getRootCategories()
819
    {
820
        return $this->getCategoryRepository()->findAllRootCategories();
821
    }
822
823
    /**
824
     * Returns the category varchar values for the categories with
825
     * the passed with the passed entity IDs.
826
     *
827
     * @param array $entityIds The array with the category IDs
828
     *
829
     * @return mixed The category varchar values
830
     */
831
    public function getCategoryVarcharsByEntityIds(array $entityIds)
832
    {
833
        return $this->getCategoryVarcharRepository()->findAllByEntityIds($entityIds);
834
    }
835
836
    /**
837
     * Return's an array with all available link types.
838
     *
839
     * @return array The available link types
840
     */
841
    public function getLinkTypes()
842
    {
843
        return $this->getLinkTypeRepository()->findAll();
844
    }
845
846
    /**
847
     * Return's an array with all available link attributes.
848
     *
849
     * @return array The available link attributes
850
     */
851
    public function getLinkAttributes()
852
    {
853
        return $this->getLinkAttributeRepository()->findAll();
854
    }
855
856
    /**
857
     * Return's an array with the Magento 2 configuration.
858
     *
859
     * @return array The Magento 2 configuration
860
     */
861
    public function getCoreConfigData()
862
    {
863
        return $this->getCoreConfigDataRepository()->findAll();
864
    }
865
866
    /**
867
     * Persist's the passed store.
868
     *
869
     * @param array $store The store to persist
870
     *
871
     * @return void
872
     */
873
    public function persistStore(array $store)
874
    {
875
        return $this->getStoreAction()->persist($store);
876
    }
877
878
    /**
879
     * Persist's the passed store group.
880
     *
881
     * @param array $storeGroup The store group to persist
882
     *
883
     * @return void
884
     */
885
    public function persistStoreGroup(array $storeGroup)
886
    {
887
        return $this->getStoreGroupAction()->persist($storeGroup);
888
    }
889
890
    /**
891
     * Persist's the passed store website.
892
     *
893
     * @param array $storeWebsite The store website to persist
894
     *
895
     * @return void
896
     */
897
    public function persistStoreWebsite(array $storeWebsite)
898
    {
899
        return $this->getStoreWebsiteAction()->persist($storeWebsite);
900
    }
901
902
    /**
903
     * Returns the array with the global data necessary for the
904
     * import process.
905
     *
906
     * @return array The array with the global data
907
     */
908
    public function getGlobalData()
909
    {
910
911
        // initialize the array for the global data
912
        $globalData = array();
913
914
        // initialize the global data
915
        $globalData[RegistryKeys::STORES] = $this->getStores();
916
        $globalData[RegistryKeys::LINK_TYPES] = $this->getLinkTypes();
917
        $globalData[RegistryKeys::TAX_CLASSES] = $this->getTaxClasses();
918
        $globalData[RegistryKeys::DEFAULT_STORE] = $this->getDefaultStore();
919
        $globalData[RegistryKeys::STORE_WEBSITES] = $this->getStoreWebsites();
920
        $globalData[RegistryKeys::LINK_ATTRIBUTES] = $this->getLinkAttributes();
921
        $globalData[RegistryKeys::ROOT_CATEGORIES] = $this->getRootCategories();
922
        $globalData[RegistryKeys::CORE_CONFIG_DATA] = $this->getCoreConfigData();
923
        $globalData[RegistryKeys::ENTITY_TYPES] = $eavEntityTypes = $this->getEavEntityTypes();
924
925
        // prepare the attribute sets
926
        $eavAttributes = array();
927
        $eavAttributeSets = array();
928
        $eavAttributeGroups = array();
929
        foreach ($eavEntityTypes as $eavEntityTypeCode => $eavEntityType) {
930
            // load the attribute sets for the entity type
931
            $attributeSets = $this->getEavAttributeSetsByEntityTypeId($entityTypeId = $eavEntityType[MemberNames::ENTITY_TYPE_ID]);
932
            // append the attribute sets to the array
933
            $eavAttributeSets[$eavEntityTypeCode] = $attributeSets;
934
935
            // iterate over the attribute sets and initialize the attributes
936
            foreach ($attributeSets as $attributeSet) {
0 ignored issues
show
Bug introduced by
The expression $attributeSets of type array|boolean is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
937
                // load the attribute set name
938
                $eavAttributeSetName = $attributeSet[MemberNames::ATTRIBUTE_SET_NAME];
939
940
                // load the attributes for the attribute set
941
                $eavAttributes[$eavEntityTypeCode][$eavAttributeSetName] = $this->getEavAttributesByEntityTypeIdAndAttributeSetName(
942
                    $entityTypeId,
943
                    $eavAttributeSetName
944
                );
945
946
                // load the attribute group for the attribute set
947
                $eavAttributeGroups[$eavEntityTypeCode][$eavAttributeSetName] = $this->getEavAttributeGroupsByAttributeSetId(
948
                    $attributeSet[MemberNames::ATTRIBUTE_SET_ID]
949
                );
950
            }
951
        }
952
953
        // prepare the user defined attributes
954
        $eavUserDefinedAttributes = array();
955
        foreach ($eavEntityTypes as $eavEntityTypeCode => $eavEntityType) {
956
            // load the user defined attributes for the entity type
957
            $eavUserDefinedAttributes[$eavEntityTypeCode] = $this->getEavAttributesByEntityTypeIdAndIsUserDefined(
958
                $eavEntityType[MemberNames::ENTITY_TYPE_ID]
959
            );
960
        }
961
962
        // initialize the arrays with the EAV attributes, EAV user defined attributes and attribute sets/groups
963
        $globalData[RegistryKeys::EAV_ATTRIBUTES] = $eavAttributes;
964
        $globalData[RegistryKeys::ATTRIBUTE_SETS] = $eavAttributeSets;
965
        $globalData[RegistryKeys::ATTRIBUTE_GROUPS] = $eavAttributeGroups;
966
        $globalData[RegistryKeys::EAV_USER_DEFINED_ATTRIBUTES] = $eavUserDefinedAttributes;
967
968
        // initialize the array with the avaliable categories
969
        $globalData[RegistryKeys::CATEGORIES] = $this->categoryAssembler->getCategoriesWithResolvedPath();
970
971
        // return the array
972
        return $globalData;
973
    }
974
}
975