Completed
Push — 17.x ( 3fdb9b...8eca03 )
by Tim
02:21
created

setAttributeOptionValueAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Attribute\Services\AttributeBunchProcessor
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 2019 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-attribute
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Attribute\Services;
22
23
use TechDivision\Import\Actions\ActionInterface;
24
use TechDivision\Import\Connection\ConnectionInterface;
25
use TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface;
26
use TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface;
27
use TechDivision\Import\Attribute\Repositories\AttributeRepositoryInterface;
28
use TechDivision\Import\Attribute\Repositories\AttributeLabelRepositoryInterface;
29
use TechDivision\Import\Attribute\Repositories\AttributeOptionRepositoryInterface;
30
use TechDivision\Import\Attribute\Repositories\EntityAttributeRepositoryInterface;
31
use TechDivision\Import\Attribute\Repositories\CatalogAttributeRepositoryInterface;
32
use TechDivision\Import\Attribute\Repositories\AttributeOptionSwatchRepositoryInterface;
33
34
/**
35
 * The attribute bunch processor implementation.
36
 *
37
 * @author    Tim Wagner <[email protected]>
38
 * @copyright 2019 TechDivision GmbH <[email protected]>
39
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
40
 * @link      https://github.com/techdivision/import-attribute
41
 * @link      http://www.techdivision.com
42
 */
43
class AttributeBunchProcessor implements AttributeBunchProcessorInterface
44
{
45
46
    /**
47
     * A connection to use.
48
     *
49
     * @var \TechDivision\Import\Connection\ConnectionInterface
50
     */
51
    protected $connection;
52
53
    /**
54
     * The attribute repository instance.
55
     *
56
     * @var \TechDivision\Import\Attribute\Repositories\AttributeRepositoryInterface
57
     */
58
    protected $attributeRepository;
59
60
    /**
61
     * The attribute label repository instance.
62
     *
63
     * @var \TechDivision\Import\Attribute\Repositories\AttributeLabelRepositoryInterface
64
     */
65
    protected $attributeLabelRepository;
66
67
    /**
68
     * The attribute option repository instance.
69
     *
70
     * @var \TechDivision\Import\Attribute\Repositories\AttributeOptionRepositoryInterface
71
     */
72
    protected $attributeOptionRepository;
73
74
    /**
75
     * The repository to access EAV attribute option values.
76
     *
77
     * @var \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface
78
     */
79
    protected $eavAttributeOptionValueRepository;
80
81
    /**
82
     * The attribute option swatch repository instance.
83
     *
84
     * @var \TechDivision\Import\Attribute\Repositories\AttributeOptionSwatchRepositoryInterface
85
     */
86
    protected $attributeOptionSwatchRepository;
87
88
    /**
89
     * The catalog attribute repository instance.
90
     *
91
     * @var \TechDivision\Import\Attribute\Repositories\CatalogAttributeRepositoryInterface
92
     */
93
    protected $catalogAttributeRepository;
94
95
    /**
96
     * The entity attribute repository instance.
97
     *
98
     * @var \TechDivision\Import\Attribute\Repositories\EntityAttributeRepositoryInterface
99
     */
100
    protected $entityAttributeRepository;
101
102
    /**
103
     * The EAV entity type repository instance.
104
     *
105
     * @var \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface
106
     */
107
    protected $entityTypeRepository;
108
109
    /**
110
     * The attribute action instance.
111
     *
112
     * @var \TechDivision\Import\Actions\ActionInterface
113
     */
114
    protected $attributeAction;
115
116
    /**
117
     * The attribute label action instance.
118
     *
119
     * @var \TechDivision\Import\Actions\ActionInterface
120
     */
121
    protected $attributeLabelAction;
122
123
    /**
124
     * The attribute option action instance.
125
     *
126
     * @var \TechDivision\Import\Actions\ActionInterface
127
     */
128
    protected $attributeOptionAction;
129
130
    /**
131
     * The attribute option value action instance.
132
     *
133
     * @var \TechDivision\Import\Actions\ActionInterface
134
     */
135
    protected $attributeOptionValueAction;
136
137
    /**
138
     * The attribute option swatch action instance.
139
     *
140
     * @var \TechDivision\Import\Actions\ActionInterface
141
     */
142
    protected $attributeOptionSwatchAction;
143
144
    /**
145
     * The attribute action instance.
146
     *
147
     * @var \TechDivision\Import\Actions\ActionInterface
148
     */
149
    protected $catalogAttributeAction;
150
151
    /**
152
     * The entity attribute action instance.
153
     *
154
     * @var \TechDivision\Import\Actions\ActionInterface
155
     */
156
    protected $entityAttributeAction;
157
158
    /**
159
     * Initialize the processor with the necessary assembler and repository instances.
160
     *
161
     * @param \TechDivision\Import\Connection\ConnectionInterface                                  $connection                        The connection to use
162
     * @param \TechDivision\Import\Attribute\Repositories\AttributeRepositoryInterface             $attributeRepository               The attribute repository instance
163
     * @param \TechDivision\Import\Attribute\Repositories\AttributeLabelRepositoryInterface        $attributeLabelRepository          The attribute label repository instance
164
     * @param \TechDivision\Import\Attribute\Repositories\AttributeOptionRepositoryInterface       $attributeOptionRepository         The attribute repository instance
165
     * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface         $eavAttributeOptionValueRepository The EAV attribute option value repository to use
166
     * @param \TechDivision\Import\Attribute\Repositories\AttributeOptionSwatchRepositoryInterface $attributeOptionSwatchRepository   The attribute repository swatch instance
167
     * @param \TechDivision\Import\Attribute\Repositories\CatalogAttributeRepositoryInterface      $catalogAttributeRepository        The catalog attribute repository instance
168
     * @param \TechDivision\Import\Attribute\Repositories\EntityAttributeRepositoryInterface       $entityAttributeRepository         The entity attribute repository instance
169
     * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface                   $entityTypeRepository              The entity type repository instance
170
     * @param \TechDivision\Import\Actions\ActionInterface                                         $attributeAction                   The attribute action instance
171
     * @param \TechDivision\Import\Actions\ActionInterface                                         $attributeLabelAction              The attribute label action instance
172
     * @param \TechDivision\Import\Actions\ActionInterface                                         $attributeOptionAction             The attribute option action instance
173
     * @param \TechDivision\Import\Actions\ActionInterface                                         $attributeOptionValueAction        The attribute option value action instance
174
     * @param \TechDivision\Import\Actions\ActionInterface                                         $attributeOptionSwatchAction       The attribute option swatch action instance
175
     * @param \TechDivision\Import\Actions\ActionInterface                                         $catalogAttributeAction            The catalog attribute action instance
176
     * @param \TechDivision\Import\Actions\ActionInterface                                         $entityAttributeAction             The entity attribute action instance
177
     */
178
    public function __construct(
179
        ConnectionInterface $connection,
180
        AttributeRepositoryInterface $attributeRepository,
181
        AttributeLabelRepositoryInterface $attributeLabelRepository,
182
        AttributeOptionRepositoryInterface $attributeOptionRepository,
183
        EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository,
184
        AttributeOptionSwatchRepositoryInterface $attributeOptionSwatchRepository,
185
        CatalogAttributeRepositoryInterface $catalogAttributeRepository,
186
        EntityAttributeRepositoryInterface $entityAttributeRepository,
187
        EavEntityTypeRepositoryInterface $entityTypeRepository,
188
        ActionInterface $attributeAction,
189
        ActionInterface $attributeLabelAction,
190
        ActionInterface $attributeOptionAction,
191
        ActionInterface $attributeOptionValueAction,
192
        ActionInterface $attributeOptionSwatchAction,
193
        ActionInterface $catalogAttributeAction,
194
        ActionInterface $entityAttributeAction
195
    ) {
196
        $this->setConnection($connection);
197
        $this->setAttributeRepository($attributeRepository);
198
        $this->setAttributeLabelRepository($attributeLabelRepository);
199
        $this->setAttributeOptionRepository($attributeOptionRepository);
200
        $this->setEavAttributeOptionValueRepository($eavAttributeOptionValueRepository);
201
        $this->setAttributeOptionSwatchRepository($attributeOptionSwatchRepository);
202
        $this->setCatalogAttributeRepository($catalogAttributeRepository);
203
        $this->setEntityAttributeRepository($entityAttributeRepository);
204
        $this->setEntityTypeRepository($entityTypeRepository);
205
        $this->setAttributeAction($attributeAction);
206
        $this->setAttributeLabelAction($attributeLabelAction);
207
        $this->setAttributeOptionAction($attributeOptionAction);
208
        $this->setAttributeOptionValueAction($attributeOptionValueAction);
209
        $this->setAttributeOptionSwatchAction($attributeOptionSwatchAction);
210
        $this->setCatalogAttributeAction($catalogAttributeAction);
211
        $this->setEntityAttributeAction($entityAttributeAction);
212
    }
213
214
    /**
215
     * Set's the passed connection.
216
     *
217
     * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to set
218
     *
219
     * @return void
220
     */
221
    public function setConnection(ConnectionInterface $connection)
222
    {
223
        $this->connection = $connection;
224
    }
225
226
    /**
227
     * Return's the connection.
228
     *
229
     * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance
230
     */
231
    public function getConnection()
232
    {
233
        return $this->connection;
234
    }
235
236
    /**
237
     * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO
238
     * object instance are not committed until you end the transaction by calling ProductProcessor::commit().
239
     * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection
240
     * to autocommit mode.
241
     *
242
     * @return boolean Returns TRUE on success or FALSE on failure
243
     * @link http://php.net/manual/en/pdo.begintransaction.php
244
     */
245
    public function beginTransaction()
246
    {
247
        return $this->connection->beginTransaction();
248
    }
249
250
    /**
251
     * Commits a transaction, returning the database connection to autocommit mode until the next call to
252
     * ProductProcessor::beginTransaction() starts a new transaction.
253
     *
254
     * @return boolean Returns TRUE on success or FALSE on failure
255
     * @link http://php.net/manual/en/pdo.commit.php
256
     */
257
    public function commit()
258
    {
259
        return $this->connection->commit();
260
    }
261
262
    /**
263
     * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction().
264
     *
265
     * If the database was set to autocommit mode, this function will restore autocommit mode after it has
266
     * rolled back the transaction.
267
     *
268
     * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition
269
     * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
270
     * COMMIT will prevent you from rolling back any other changes within the transaction boundary.
271
     *
272
     * @return boolean Returns TRUE on success or FALSE on failure
273
     * @link http://php.net/manual/en/pdo.rollback.php
274
     */
275
    public function rollBack()
276
    {
277
        return $this->connection->rollBack();
278
    }
279
280
    /**
281
     * Set's the attribute repository instance.
282
     *
283
     * @param \TechDivision\Import\Attribute\Repositories\AttributeRepositoryInterface $attributeRepository The attribute repository instance
284
     *
285
     * @return void
286
     */
287
    public function setAttributeRepository(AttributeRepositoryInterface $attributeRepository)
288
    {
289
        $this->attributeRepository = $attributeRepository;
290
    }
291
292
    /**
293
     * Return's the attribute repository instance.
294
     *
295
     * @return \TechDivision\Import\Attribute\Repositories\AttributeRepositoryInterface The attribute repository instance
296
     */
297
    public function getAttributeRepository()
298
    {
299
        return $this->attributeRepository;
300
    }
301
302
    /**
303
     * Set's the attribute label repository instance.
304
     *
305
     * @param \TechDivision\Import\Attribute\Repositories\AttributeLabelRepositoryInterface $attributeLabelRepository The attribute label repository instance
306
     *
307
     * @return void
308
     */
309
    public function setAttributeLabelRepository(AttributeLabelRepositoryInterface $attributeLabelRepository)
310
    {
311
        $this->attributeLabelRepository = $attributeLabelRepository;
312
    }
313
314
    /**
315
     * Return's the attribute label repository instance.
316
     *
317
     * @return \TechDivision\Import\Attribute\Repositories\AttributeLabelRepositoryInterface The attribute label repository instance
318
     */
319
    public function getAttributeLabelRepository()
320
    {
321
        return $this->attributeLabelRepository;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->attributeLabelRepository; (TechDivision\Import\Attr...abelRepositoryInterface) is incompatible with the return type declared by the interface TechDivision\Import\Attr...ttributeLabelRepository of type TechDivision\Import\Attr...buteRepositoryInterface.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
322
    }
323
324
    /**
325
     * Set's the attribute option repository instance.
326
     *
327
     * @param \TechDivision\Import\Attribute\Repositories\AttributeOptionRepositoryInterface $attributeOptionRepository The attribute option repository instance
328
     *
329
     * @return void
330
     */
331
    public function setAttributeOptionRepository(AttributeOptionRepositoryInterface $attributeOptionRepository)
332
    {
333
        $this->attributeOptionRepository = $attributeOptionRepository;
334
    }
335
336
    /**
337
     * Return's the attribute option repository instance.
338
     *
339
     * @return \TechDivision\Import\Attribute\Repositories\AttributeOptionRepositoryInterface The attribute option repository instance
340
     */
341
    public function getAttributeOptionRepository()
342
    {
343
        return $this->attributeOptionRepository;
344
    }
345
346
    /**
347
     * Set's the repository to access EAV attribute option values.
348
     *
349
     * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The repository to access EAV attribute option values
350
     *
351
     * @return void
352
     */
353
    public function setEavAttributeOptionValueRepository(EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository)
354
    {
355
        $this->eavAttributeOptionValueRepository = $eavAttributeOptionValueRepository;
356
    }
357
358
    /**
359
     * Return's the repository to access EAV attribute option values.
360
     *
361
     * @return \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface The repository instance
362
     */
363
    public function getEavAttributeOptionValueRepository()
364
    {
365
        return $this->eavAttributeOptionValueRepository;
366
    }
367
368
    /**
369
     * Set's the attribute option swatch repository instance.
370
     *
371
     * @param \TechDivision\Import\Attribute\Repositories\AttributeOptionSwatchRepositoryInterface $attributeOptionSwatchRepository The attribute option swatch repository instance
372
     *
373
     * @return void
374
     */
375
    public function setAttributeOptionSwatchRepository(AttributeOptionSwatchRepositoryInterface $attributeOptionSwatchRepository)
376
    {
377
        $this->attributeOptionSwatchRepository = $attributeOptionSwatchRepository;
378
    }
379
380
    /**
381
     * Return's the attribute option swatch repository instance.
382
     *
383
     * @return \TechDivision\Import\Attribute\Repositories\AttributeOptionSwatchRepositoryInterface The attribute option swatch repository instance
384
     */
385
    public function getAttributeOptionSwatchRepository()
386
    {
387
        return $this->attributeOptionSwatchRepository;
388
    }
389
390
    /**
391
     * Set's the catalog attribute repository instance.
392
     *
393
     * @param \TechDivision\Import\Attribute\Repositories\CatalogAttributeRepositoryInterface $catalogAttributeRepository The catalog attribute repository instance
394
     *
395
     * @return void
396
     */
397
    public function setCatalogAttributeRepository(CatalogAttributeRepositoryInterface $catalogAttributeRepository)
398
    {
399
        $this->catalogAttributeRepository = $catalogAttributeRepository;
400
    }
401
402
    /**
403
     * Return's the catalog attribute repository instance.
404
     *
405
     * @return \TechDivision\Import\Attribute\Repositories\CatalogAttributeRepositoryInterface The catalog attribute repository instance
406
     */
407
    public function getCatalogAttributeRepository()
408
    {
409
        return $this->catalogAttributeRepository;
410
    }
411
412
    /**
413
     * Set's the entity attribute repository instance.
414
     *
415
     * @param \TechDivision\Import\Attribute\Repositories\EntityAttributeRepositoryInterface $entityAttributeRepository The entity attribute repository instance
416
     *
417
     * @return void
418
     */
419
    public function setEntityAttributeRepository(EntityAttributeRepositoryInterface $entityAttributeRepository)
420
    {
421
        $this->entityAttributeRepository = $entityAttributeRepository;
422
    }
423
424
    /**
425
     * Return's the entity attribute repository instance.
426
     *
427
     * @return \TechDivision\Import\Attribute\Repositories\EntityAttributeRepositoryInterface The entity attribute repository instance
428
     */
429
    public function getEntityAttributeRepository()
430
    {
431
        return $this->entityAttributeRepository;
432
    }
433
434
    /**
435
     * Sets the EAV entity type repository.
436
     *
437
     * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface $entitTypeRepository The repository instance
438
     *
439
     * @return void
440
     */
441
    public function setEntityTypeRepository(EavEntityTypeRepositoryInterface $entitTypeRepository)
442
    {
443
        $this->entityTypeRepository = $entitTypeRepository;
444
    }
445
446
    /**
447
     * Returns the EAV entity type repository.
448
     *
449
     * @return \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface The repository instance
450
     */
451
    public function getEntityTypeRepository()
452
    {
453
        return $this->entityTypeRepository;
454
    }
455
456
    /**
457
     * Set's the attribute action instance.
458
     *
459
     * @param \TechDivision\Import\Actions\ActionInterface $attributeAction The attribute action instance
460
     *
461
     * @return void
462
     */
463
    public function setAttributeAction(ActionInterface $attributeAction)
464
    {
465
        $this->attributeAction = $attributeAction;
466
    }
467
468
    /**
469
     * Return's the attribute action instance.
470
     *
471
     * @return \TechDivision\Import\Actions\ActionInterface The attribute action instance
472
     */
473
    public function getAttributeAction()
474
    {
475
        return $this->attributeAction;
476
    }
477
478
    /**
479
     * Set's the attribute label action instance.
480
     *
481
     * @param \TechDivision\Import\Actions\ActionInterface $attributeLabelAction The attribute label action instance
482
     *
483
     * @return void
484
     */
485
    public function setAttributeLabelAction(ActionInterface $attributeLabelAction)
486
    {
487
        $this->attributeLabelAction = $attributeLabelAction;
488
    }
489
490
    /**
491
     * Return's the attribute label action instance.
492
     *
493
     * @return \TechDivision\Import\Actions\ActionInterface The attribute label action instance
494
     */
495
    public function getAttributeLabelAction()
496
    {
497
        return $this->attributeLabelAction;
498
    }
499
500
    /**
501
     * Set's the attribute option action instance.
502
     *
503
     * @param \TechDivision\Import\Actions\ActionInterface $attributeOptionAction The attribute option action instance
504
     *
505
     * @return void
506
     */
507
    public function setAttributeOptionAction(ActionInterface $attributeOptionAction)
508
    {
509
        $this->attributeOptionAction = $attributeOptionAction;
510
    }
511
512
    /**
513
     * Return's the attribute option action instance.
514
     *
515
     * @return \TechDivision\Import\Actions\ActionInterface The attribute option action instance
516
     */
517
    public function getAttributeOptionAction()
518
    {
519
        return $this->attributeOptionAction;
520
    }
521
522
    /**
523
     * Set's the attribute option value action instance.
524
     *
525
     * @param \TechDivision\Import\Actions\ActionInterface $attributeOptionValueAction The attribute option value action instance
526
     *
527
     * @return void
528
     */
529
    public function setAttributeOptionValueAction(ActionInterface $attributeOptionValueAction)
530
    {
531
        $this->attributeOptionValueAction = $attributeOptionValueAction;
532
    }
533
534
    /**
535
     * Return's the attribute option value action instance.
536
     *
537
     * @return \TechDivision\Import\Actions\ActionInterface The attribute option value action instance
538
     */
539
    public function getAttributeOptionValueAction()
540
    {
541
        return $this->attributeOptionValueAction;
542
    }
543
544
    /**
545
     * Set's the attribute option swatch action instance.
546
     *
547
     * @param \TechDivision\Import\Actions\ActionInterface $attributeOptionSwatchAction The attribute option swatch action instance
548
     *
549
     * @return void
550
     */
551
    public function setAttributeOptionSwatchAction(ActionInterface $attributeOptionSwatchAction)
552
    {
553
        $this->attributeOptionSwatchAction = $attributeOptionSwatchAction;
554
    }
555
556
    /**
557
     * Return's the attribute option swatch action instance.
558
     *
559
     * @return \TechDivision\Import\Actions\ActionInterface The attribute option swatch action instance
560
     */
561
    public function getAttributeOptionSwatchAction()
562
    {
563
        return $this->attributeOptionSwatchAction;
564
    }
565
566
    /**
567
     * Set's the catalog attribute action instance.
568
     *
569
     * @param \TechDivision\Import\Actions\ActionInterface $catalogAttributeAction The catalog attribute action instance
570
     *
571
     * @return void
572
     */
573
    public function setCatalogAttributeAction(ActionInterface $catalogAttributeAction)
574
    {
575
        $this->catalogAttributeAction = $catalogAttributeAction;
576
    }
577
578
    /**
579
     * Return's the catalog attribute action instance.
580
     *
581
     * @return \TechDivision\Import\Actions\ActionInterface The catalog attribute action instance
582
     */
583
    public function getCatalogAttributeAction()
584
    {
585
        return $this->catalogAttributeAction;
586
    }
587
588
    /**
589
     * Set's the entity attribute action instance.
590
     *
591
     * @param \TechDivision\Import\Actions\ActionInterface $entityAttributeAction The entity attribute action instance
592
     *
593
     * @return void
594
     */
595
    public function setEntityAttributeAction(ActionInterface $entityAttributeAction)
596
    {
597
        $this->entityAttributeAction = $entityAttributeAction;
598
    }
599
600
    /**
601
     * Return's the entity attribute action instance.
602
     *
603
     * @return \TechDivision\Import\Actions\ActionInterface The entity attribute action instance
604
     */
605
    public function getEntityAttributeAction()
606
    {
607
        return $this->entityAttributeAction;
608
    }
609
610
    /**
611
     * Return's the EAV attribute label with the passed attribute code and store ID.
612
     *
613
     * @param integer $entityTypeId  The ID of the EAV entity attribute to return the label for
614
     * @param string  $attributeCode The attribute code of the EAV attribute label to return
615
     * @param integer $storeId       The store ID of the EAV attribute label to return
616
     *
617
     * @return array The EAV attribute label
618
     */
619
    public function loadAttributeLabelByEntityTypeIdAndAttributeCodeAndStoreId($entityTypeId, $attributeCode, $storeId)
620
    {
621
        return $this->getAttributeLabelRepository()->findOneByEntityTypeIdAndAttributeCodeAndStoreId($entityTypeId, $attributeCode, $storeId);
622
    }
623
624
    /**
625
     * Load's and return's the EAV attribute option value with the passed option ID and store ID.
626
     *
627
     * @param string  $optionId The option ID
628
     * @param integer $storeId  The store ID of the attribute option to load
629
     *
630
     * @return array The EAV attribute option value
631
     */
632
    public function loadAttributeOptionValueByOptionIdAndStoreId($optionId, $storeId)
633
    {
634
        return $this->getEavAttributeOptionValueRepository()->findOneByOptionIdAndStoreId($optionId, $storeId);
635
    }
636
637
    /**
638
     * Load's and return's the EAV attribute option swatch with the passed option ID and store ID
639
     *
640
     * @param integer $optionId The option ID of the attribute option swatch to load
641
     * @param integer $storeId  The store ID of the attribute option swatch to load
642
     *
643
     * @return array The EAV attribute option swatch
644
     */
645
    public function loadAttributeOptionSwatchByOptionIdAndStoreId($optionId, $storeId)
646
    {
647
        return $this->getAttributeOptionSwatchRepository()->findOneByOptionIdAndStoreId($optionId, $storeId);
648
    }
649
650
    /**
651
     * Load's and retur's the EAV catalog attribute with the passed ID.
652
     *
653
     * @param string $attributeId The ID of the EAV catalog attribute to return
654
     *
655
     * @return array The EAV catalog attribute
656
     */
657
    public function loadCatalogAttribute($attributeId)
658
    {
659
        return $this->getCatalogAttributeRepository()->load($attributeId);
660
    }
661
662
    /**
663
     * Return's the EAV entity attribute with the passed attribute and attribute set ID.
664
     *
665
     * @param integer $attributeId    The ID of the EAV entity attribute's attribute to return
666
     * @param integer $attributeSetId The ID of the EAV entity attribute's attribute set to return
667
     *
668
     * @return array The EAV entity attribute
669
     */
670
    public function loadEntityAttributeByAttributeIdAndAttributeSetId($attributeId, $attributeSetId)
671
    {
672
        return $this->getEntityAttributeRepository()->findOneByAttributeIdAndAttributeSetId($attributeId, $attributeSetId);
673
    }
674
675
    /**
676
     * Return's the EAV entity attribute with the passed entity type, attribute, attribute set and attribute group ID.
677
     *
678
     * @param integer $entityTypeId     The ID of the EAV entity attribute's entity type to return
679
     * @param integer $attributeId      The ID of the EAV entity attribute's attribute to return
680
     * @param integer $attributeSetId   The ID of the EAV entity attribute's attribute set to return
681
     * @param integer $attributeGroupId The ID of the EAV entity attribute's attribute group to return
682
     *
683
     * @return array The EAV entity attribute
684
     */
685
    public function loadEntityAttributeByEntityTypeIdAndAttributeIdAndAttributeSetIdAndAttributeGroupId($entityTypeId, $attributeId, $attributeSetId, $attributeGroupId)
686
    {
687
        return $this->getEntityAttributeRepository()->findOneByEntityTypeIdAndAttributeIdAndAttributeSetIdAndAttributeGroupId($entityTypeId, $attributeId, $attributeSetId, $attributeGroupId);
688
    }
689
690
    /**
691
     * Return's an EAV entity type with the passed entity type code.
692
     *
693
     * @param string $entityTypeCode The code of the entity type to return
694
     *
695
     * @return array The entity type with the passed entity type code
696
     */
697
    public function loadEntityTypeByEntityTypeCode($entityTypeCode)
698
    {
699
        return $this->getEntityTypeRepository()->findOneByEntityTypeCode($entityTypeCode);
700
    }
701
702
    /**
703
     * Return's the EAV attribute with the passed entity type ID and code.
704
     *
705
     * @param integer $entityTypeId  The entity type ID of the EAV attribute to return
706
     * @param string  $attributeCode The code of the EAV attribute to return
707
     *
708
     * @return array The EAV attribute
709
     */
710
    public function loadAttributeByEntityTypeIdAndAttributeCode($entityTypeId, $attributeCode)
711
    {
712
        return $this->getAttributeRepository()->findOneByEntityIdAndAttributeCode($entityTypeId, $attributeCode);
713
    }
714
715
    /**
716
     * Load's and return's the EAV attribute option with the passed entity type ID, code, store ID and value.
717
     *
718
     * @param string  $entityTypeId  The entity type ID of the EAV attribute to load the option for
719
     * @param string  $attributeCode The code of the EAV attribute option to load
720
     * @param integer $storeId       The store ID of the attribute option to load
721
     * @param string  $value         The value of the attribute option to load
722
     *
723
     * @return array The EAV attribute option
724
     */
725
    public function loadAttributeOptionByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value)
726
    {
727
        return $this->getAttributeOptionRepository()->findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value);
728
    }
729
730
    /**
731
     * Load's and return's the EAV attribute option with the passed entity type ID and code, store ID, swatch and type.
732
     *
733
     * @param string  $entityTypeId  The entity type ID of the EAV attribute to load the option for
734
     * @param string  $attributeCode The code of the EAV attribute option to load
735
     * @param integer $storeId       The store ID of the attribute option to load
736
     * @param string  $swatch        The swatch of the attribute option to load
737
     * @param string  $type          The swatch type of the attribute option to load
738
     *
739
     * @return array The EAV attribute option
740
     */
741
    public function loadAttributeOptionByEntityTypeIdAndAttributeCodeAndStoreIdAndSwatchAndType($entityTypeId, $attributeCode, $storeId, $swatch, $type)
742
    {
743
        return $this->getAttributeOptionRepostory()->findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndSwatchAndType($entityTypeId, $attributeCode, $storeId, $swatch, $type);
0 ignored issues
show
Bug introduced by
The method getAttributeOptionRepostory() does not exist on TechDivision\Import\Attr...AttributeBunchProcessor. Did you maybe mean getAttributeOptionRepository()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
744
    }
745
746
    /**
747
     * Load's and return's the EAV attribute option value with the passed code, store ID and value.
748
     *
749
     * @param string  $entityTypeId  The entity type ID of the EAV attribute to load th option for
750
     * @param string  $attributeCode The code of the EAV attribute option to load
751
     * @param integer $storeId       The store ID of the attribute option to load
752
     * @param string  $value         The value of the attribute option to load
753
     *
754
     * @return array The EAV attribute option value
755
     */
756
    public function loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value)
757
    {
758
        return $this->getEavAttributeOptionValueRepository()->findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value);
759
    }
760
761
    /**
762
     * Load's and return's the EAV attribute option swatch with the passed code, store ID, value and type.
763
     *
764
     * @param string  $entityTypeId  The entity type ID of the EAV attribute to load th option for
765
     * @param string  $attributeCode The code of the EAV attribute option swatch to load
766
     * @param integer $storeId       The store ID of the attribute option swatch to load
767
     * @param string  $value         The value of the attribute option swatch to load
768
     * @param string  $type          The type of the attribute option swatch to load
769
     *
770
     * @return array The EAV attribute option swatch
771
     */
772
    public function loadAttributeOptionSwatchByEntityTypeIdAndAttributeCodeAndStoreIdAndValueAndType($entityTypeId, $attributeCode, $storeId, $value, $type)
773
    {
774
        return $this->getAttributeOptionSwatchRepository()->findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndValueAndType($entityTypeId, $attributeCode, $storeId, $value, $type);
775
    }
776
777
    /**
778
     * Returns the EAV attribute option of attribute with the passed ID with the highest sort order.
779
     *
780
     * @param integer $attributeId The ID of the attribute to return the EAV option with the highest sort order for
781
     *
782
     * @return array|null The EAV attribute option with the highest sort order
783
     */
784
    public function loadAttributeOptionByAttributeIdAndHighestSortOrder($attributeId)
785
    {
786
        return $this->getAttributeOptionRepository()->findOneByAttributeIdAndHighestSortOrder($attributeId);
787
    }
788
789
    /**
790
     * Persist's the passed EAV attribute data and return's the ID.
791
     *
792
     * @param array       $attribute The attribute data to persist
793
     * @param string|null $name      The name of the prepared statement that has to be executed
794
     *
795
     * @return string The ID of the persisted attribute
796
     */
797
    public function persistAttribute(array $attribute, $name = null)
798
    {
799
        return $this->getAttributeAction()->persist($attribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
800
    }
801
802
    /**
803
     * Persist the passed attribute label.
804
     *
805
     * @param array       $attributeLabel The attribute label to persist
806
     * @param string|null $name           The name of the prepared statement that has to be executed
807
     *
808
     * @return void
809
     */
810
    public function persistAttributeLabel(array $attributeLabel, $name = null)
811
    {
812
        $this->getAttributeLabelAction()->persist($attributeLabel, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
813
    }
814
815
    /**
816
     * Persist's the passed EAV attribute option data and return's the ID.
817
     *
818
     * @param array       $attributeOption The attribute option data to persist
819
     * @param string|null $name            The name of the prepared statement that has to be executed
820
     *
821
     * @return string The ID of the persisted attribute
822
     */
823
    public function persistAttributeOption(array $attributeOption, $name = null)
824
    {
825
        return $this->getAttributeOptionAction()->persist($attributeOption, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
826
    }
827
828
    /**
829
     * Persist's the passed EAV attribute option value data and return's the ID.
830
     *
831
     * @param array       $attributeOptionValue The attribute option value data to persist
832
     * @param string|null $name                 The name of the prepared statement that has to be executed
833
     *
834
     * @return void
835
     */
836
    public function persistAttributeOptionValue(array $attributeOptionValue, $name = null)
837
    {
838
        $this->getAttributeOptionValueAction()->persist($attributeOptionValue, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
839
    }
840
841
    /**
842
     * Persist the passed attribute option swatch.
843
     *
844
     * @param array       $attributeOptionSwatch The attribute option swatch to persist
845
     * @param string|null $name                  The name of the prepared statement that has to be executed
846
     *
847
     * @return void
848
     */
849
    public function persistAttributeOptionSwatch(array $attributeOptionSwatch, $name = null)
850
    {
851
        $this->getAttributeOptionSwatchAction()->persist($attributeOptionSwatch, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
852
    }
853
854
    /**
855
     * Persist's the passed EAV catalog attribute data and return's the ID.
856
     *
857
     * @param array       $catalogAttribute The catalog attribute data to persist
858
     * @param string|null $name             The name of the prepared statement that has to be executed
859
     *
860
     * @return void
861
     */
862
    public function persistCatalogAttribute(array $catalogAttribute, $name = null)
863
    {
864
        $this->getCatalogAttributeAction()->persist($catalogAttribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
865
    }
866
867
    /**
868
     * Persist's the passed EAV entity attribute data and return's the ID.
869
     *
870
     * @param array       $entityAttribute The entity attribute data to persist
871
     * @param string|null $name            The name of the prepared statement that has to be executed
872
     *
873
     * @return void
874
     */
875
    public function persistEntityAttribute(array $entityAttribute, $name = null)
876
    {
877
        $this->getEntityAttributeAction()->persist($entityAttribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to ActionInterface::persist() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
878
    }
879
880
    /**
881
     * Delete's the EAV attribute with the passed attributes.
882
     *
883
     * @param array       $row  The attributes of the EAV attribute to delete
884
     * @param string|null $name The name of the prepared statement that has to be executed
885
     *
886
     * @return void
887
     */
888
    public function deleteAttribute($row, $name = null)
889
    {
890
        $this->getAttributeAction()->delete($row, $name);
891
    }
892
}
893