Completed
Push — master ( 49f402...afcc4c )
by Tim
12s
created

AbstractAttributeImportObserver::getDefaultValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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