1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * TechDivision\Import\Customer\Address\Subjects\AbstractAddressCustomerSubject |
||||||
5 | * |
||||||
6 | * PHP version 7 |
||||||
7 | * |
||||||
8 | * @author Tim Wagner <[email protected]> |
||||||
9 | * @copyright 2018 TechDivision GmbH <[email protected]> |
||||||
10 | * @license https://opensource.org/licenses/MIT |
||||||
11 | * @link https://github.com/techdivision/import-customer-address |
||||||
12 | * @link http://www.techdivision.com |
||||||
13 | */ |
||||||
14 | |||||||
15 | namespace TechDivision\Import\Customer\Address\Subjects; |
||||||
16 | |||||||
17 | use TechDivision\Import\Subjects\AbstractEavSubject; |
||||||
18 | use TechDivision\Import\Subjects\EntitySubjectInterface; |
||||||
19 | use TechDivision\Import\Customer\Address\Utils\MemberNames; |
||||||
20 | use TechDivision\Import\Customer\Address\Utils\RegistryKeys; |
||||||
21 | use TechDivision\Import\Customer\Address\Utils\ConfigurationKeys; |
||||||
22 | |||||||
23 | /** |
||||||
24 | * The abstract customer subject implementation that provides basic customer address |
||||||
25 | * handling business logic. |
||||||
26 | * |
||||||
27 | * @author Tim Wagner <[email protected]> |
||||||
28 | * @copyright 2018 TechDivision GmbH <[email protected]> |
||||||
29 | * @license https://opensource.org/licenses/MIT |
||||||
30 | * @link https://github.com/techdivision/import-customer-address |
||||||
31 | * @link http://www.techdivision.com |
||||||
32 | */ |
||||||
33 | abstract class AbstractCustomerAddressSubject extends AbstractEavSubject implements EntitySubjectInterface |
||||||
34 | { |
||||||
35 | |||||||
36 | /** |
||||||
37 | * The available country regions. |
||||||
38 | * |
||||||
39 | * @var array |
||||||
40 | */ |
||||||
41 | protected $countryRegions = array(); |
||||||
42 | |||||||
43 | /** |
||||||
44 | * The ID of the product that has been created recently. |
||||||
45 | * |
||||||
46 | * @var string |
||||||
47 | */ |
||||||
48 | protected $lastEntityId; |
||||||
49 | |||||||
50 | /** |
||||||
51 | * The available store websites. |
||||||
52 | * |
||||||
53 | * @var array |
||||||
54 | */ |
||||||
55 | protected $storeWebsites = array(); |
||||||
56 | |||||||
57 | /** |
||||||
58 | * Set's the ID of the product that has been created recently. |
||||||
59 | * |
||||||
60 | * @param string $lastEntityId The entity ID |
||||||
61 | * |
||||||
62 | * @return void |
||||||
63 | */ |
||||||
64 | public function setLastEntityId($lastEntityId) |
||||||
65 | { |
||||||
66 | $this->lastEntityId = $lastEntityId; |
||||||
67 | } |
||||||
68 | |||||||
69 | /** |
||||||
70 | * Return's the ID of the product that has been created recently. |
||||||
71 | * |
||||||
72 | * @return string The entity Id |
||||||
73 | */ |
||||||
74 | public function getLastEntityId() |
||||||
75 | { |
||||||
76 | return $this->lastEntityId; |
||||||
0 ignored issues
–
show
|
|||||||
77 | } |
||||||
78 | |||||||
79 | /** |
||||||
80 | * Queries whether or not the passed PK and store view code has already been processed. |
||||||
81 | * |
||||||
82 | * @param string $pk The PK to check been processed |
||||||
83 | * @param string $storeViewCode The store view code to check been processed |
||||||
84 | * |
||||||
85 | * @return boolean TRUE if the PK and store view code has been processed, else FALSE |
||||||
86 | */ |
||||||
87 | public function storeViewHasBeenProcessed($pk, $storeViewCode) |
||||||
0 ignored issues
–
show
The parameter
$storeViewCode is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() The parameter
$pk is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
88 | { |
||||||
89 | return false; |
||||||
90 | } |
||||||
91 | |||||||
92 | /** |
||||||
93 | * Intializes the previously loaded global data for exactly one bunch. |
||||||
94 | * |
||||||
95 | * @param string $serial The serial of the actual import |
||||||
96 | * |
||||||
97 | * @return void |
||||||
98 | */ |
||||||
99 | public function setUp($serial) |
||||||
100 | { |
||||||
101 | |||||||
102 | // load the status of the actual import |
||||||
103 | $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS); |
||||||
104 | |||||||
105 | if (isset($status[RegistryKeys::GLOBAL_DATA])) { |
||||||
106 | // load the global data we've prepared initially |
||||||
107 | $this->storeWebsites = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::STORE_WEBSITES]; |
||||||
108 | $this->countryRegions = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::COUNTRY_REGIONS]; |
||||||
109 | } |
||||||
110 | |||||||
111 | // invoke the parent method |
||||||
112 | parent::setUp($serial); |
||||||
113 | } |
||||||
114 | |||||||
115 | /** |
||||||
116 | * Return's the store website for the passed code. |
||||||
117 | * |
||||||
118 | * @param string $code The code of the store website to return the ID for |
||||||
119 | * |
||||||
120 | * @return integer The store website ID |
||||||
121 | * @throws \Exception Is thrown, if the store website with the requested code is not available |
||||||
122 | */ |
||||||
123 | public function getStoreWebsiteIdByCode($code) |
||||||
124 | { |
||||||
125 | |||||||
126 | // query whether or not, the requested store website is available |
||||||
127 | if (isset($this->storeWebsites[$code])) { |
||||||
128 | return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID]; |
||||||
129 | } |
||||||
130 | |||||||
131 | // throw an exception, if not |
||||||
132 | throw new \Exception( |
||||||
133 | $this->appendExceptionSuffix( |
||||||
134 | sprintf('Found invalid website code %s', $code) |
||||||
135 | ) |
||||||
136 | ); |
||||||
137 | } |
||||||
138 | |||||||
139 | /** |
||||||
140 | * @param string $code The code of the region code to return the region ID for |
||||||
141 | * @return integer|null |
||||||
142 | */ |
||||||
143 | public function getCountryRegionIdByCode($code) |
||||||
144 | { |
||||||
145 | if (isset($this->countryRegions[$code])) { |
||||||
146 | return (integer)$this->countryRegions[$code][MemberNames::REGION_ID]; |
||||||
147 | } |
||||||
148 | return null; |
||||||
149 | } |
||||||
150 | |||||||
151 | /** |
||||||
152 | * Merge the columns from the configuration with all image type columns to define which |
||||||
153 | * columns should be cleaned-up. |
||||||
154 | * |
||||||
155 | * @return array The columns that has to be cleaned-up |
||||||
156 | */ |
||||||
157 | public function getCleanUpColumns() |
||||||
158 | { |
||||||
159 | return $this->getConfiguration()->getParam(ConfigurationKeys::CLEAN_UP_EMPTY_COLUMNS); |
||||||
160 | } |
||||||
161 | } |
||||||
162 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: