Completed
Pull Request — master (#5)
by Tim
02:21
created

addAttributeCodeIdMapping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Attribute\Observers\AbstractAttributeImportObserver
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-attribute
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Attribute\Observers;
22
23
use TechDivision\Import\Observers\AbstractObserver;
24
use TechDivision\Import\Attribute\Utils\ColumnKeys;
25
26
/**
27
 * Abstract attribute observer that handles the process to import attribute bunches.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2016 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
abstract class AbstractAttributeImportObserver extends AbstractObserver implements AttributeImportObserverInterface
36
{
37
38
    /**
39
     * Will be invoked by the action on the events the listener has been registered for.
40
     *
41
     * @param array $row The row to handle
42
     *
43
     * @return array The modified row
44
     * @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle()
45
     */
46
    public function handle(array $row)
47
    {
48
49
        // initialize the row
50
        $this->setRow($row);
51
52
        // process the functionality and return the row
53
        $this->process();
54
55
        // return the processed row
56
        return $this->getRow();
57
    }
58
59
    /**
60
     * Return's whether or not this is the admin store view.
61
     *
62
     * @return boolean TRUE if we're in admin store view, else FALSE
63
     */
64
    protected function isAdminStore()
65
    {
66
        return $this->getValue(ColumnKeys::STORE_VIEW_CODE) === null;
67
    }
68
69
    /**
70
     * Process the observer's business logic.
71
     *
72
     * @return void
73
     */
74
    abstract protected function process();
75
}
76