@@ 93-168 (lines=76) @@ | ||
90 | * @return mixed The configuration value |
|
91 | * @throws \Exception Is thrown, if nor a value can be found or a default value has been passed |
|
92 | */ |
|
93 | public function load($path = null, $default = null, $scope = ScopeKeys::SCOPE_DEFAULT, $scopeId = 0) |
|
94 | { |
|
95 | ||
96 | // initialize the core config data |
|
97 | $coreConfigData = array( |
|
98 | MemberNames::PATH => $path, |
|
99 | MemberNames::SCOPE => $scope, |
|
100 | MemberNames::SCOPE_ID => $scopeId |
|
101 | ); |
|
102 | ||
103 | // generate the UID from the passed data |
|
104 | $uniqueIdentifier = $this->coreConfigDataUidGenerator->generate($coreConfigData); |
|
105 | ||
106 | // iterate over the core config data and try to find the requested configuration value |
|
107 | if (isset($this->coreConfigData[$uniqueIdentifier])) { |
|
108 | return $this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE]; |
|
109 | } |
|
110 | ||
111 | // query whether or not we've to query for the configuration value on fallback level 'websites' also |
|
112 | if ($scope === ScopeKeys::SCOPE_STORES) { |
|
113 | // query whether or not the website with the passed ID is available |
|
114 | foreach ($this->storeWebsites as $storeWebsite) { |
|
115 | if ($storeWebsite[MemberNames::WEBSITE_ID] === $scopeId) { |
|
116 | // replace scope with 'websites' and website ID |
|
117 | $coreConfigData = array_merge( |
|
118 | $coreConfigData, |
|
119 | array( |
|
120 | MemberNames::SCOPE => ScopeKeys::SCOPE_WEBSITES, |
|
121 | MemberNames::SCOPE_ID => $storeWebsite[MemberNames::WEBSITE_ID] |
|
122 | ) |
|
123 | ); |
|
124 | ||
125 | // generate the UID from the passed data, merged with the 'websites' scope and ID |
|
126 | $uniqueIdentifier = $this->coreConfigDataUidGenerator->generate($coreConfigData); |
|
127 | ||
128 | // query whether or not, the configuration value on 'websites' level |
|
129 | if (isset($this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE])) { |
|
130 | return $this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE]; |
|
131 | } |
|
132 | } |
|
133 | } |
|
134 | } |
|
135 | ||
136 | // replace scope with 'default' and scope ID '0' |
|
137 | $coreConfigData = array_merge( |
|
138 | $coreConfigData, |
|
139 | array( |
|
140 | MemberNames::SCOPE => ScopeKeys::SCOPE_DEFAULT, |
|
141 | MemberNames::SCOPE_ID => 0 |
|
142 | ) |
|
143 | ); |
|
144 | ||
145 | // generate the UID from the passed data, merged with the 'default' scope and ID 0 |
|
146 | $uniqueIdentifier = $this->coreConfigDataUidGenerator->generate($coreConfigData); |
|
147 | ||
148 | // query whether or not, the configuration value on 'default' level |
|
149 | if (isset($this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE])) { |
|
150 | return $this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE]; |
|
151 | } |
|
152 | ||
153 | // if not, return the passed default value |
|
154 | if ($default !== null) { |
|
155 | return $default; |
|
156 | } |
|
157 | ||
158 | // throw an exception if no value can be found |
|
159 | // in the Magento configuration |
|
160 | throw new \Exception( |
|
161 | sprintf( |
|
162 | 'Can\'t find a value for configuration "%s-%s-%d" in "core_config_data"', |
|
163 | $path, |
|
164 | $scope, |
|
165 | $scopeId |
|
166 | ) |
|
167 | ); |
|
168 | } |
|
169 | } |
|
170 |
@@ 1270-1345 (lines=76) @@ | ||
1267 | * @throws \Exception Is thrown, if nor a value can be found or a default value has been passed |
|
1268 | * @deprecated Since version 17.x, use TechDivision\Import\Loaders\CoreConfigDataLoader::load() method instead |
|
1269 | */ |
|
1270 | public function getCoreConfigData($path, $default = null, $scope = ScopeKeys::SCOPE_DEFAULT, $scopeId = 0) |
|
1271 | { |
|
1272 | ||
1273 | // initialize the core config data |
|
1274 | $coreConfigData = array( |
|
1275 | MemberNames::PATH => $path, |
|
1276 | MemberNames::SCOPE => $scope, |
|
1277 | MemberNames::SCOPE_ID => $scopeId |
|
1278 | ); |
|
1279 | ||
1280 | // generate the UID from the passed data |
|
1281 | $uniqueIdentifier = $this->coreConfigDataUidGenerator->generate($coreConfigData); |
|
1282 | ||
1283 | // iterate over the core config data and try to find the requested configuration value |
|
1284 | if (isset($this->coreConfigData[$uniqueIdentifier])) { |
|
1285 | return $this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE]; |
|
1286 | } |
|
1287 | ||
1288 | // query whether or not we've to query for the configuration value on fallback level 'websites' also |
|
1289 | if ($scope === ScopeKeys::SCOPE_STORES) { |
|
1290 | // query whether or not the website with the passed ID is available |
|
1291 | foreach ($this->storeWebsites as $storeWebsite) { |
|
1292 | if ($storeWebsite[MemberNames::WEBSITE_ID] === $scopeId) { |
|
1293 | // replace scope with 'websites' and website ID |
|
1294 | $coreConfigData = array_merge( |
|
1295 | $coreConfigData, |
|
1296 | array( |
|
1297 | MemberNames::SCOPE => ScopeKeys::SCOPE_WEBSITES, |
|
1298 | MemberNames::SCOPE_ID => $storeWebsite[MemberNames::WEBSITE_ID] |
|
1299 | ) |
|
1300 | ); |
|
1301 | ||
1302 | // generate the UID from the passed data, merged with the 'websites' scope and ID |
|
1303 | $uniqueIdentifier = $this->coreConfigDataUidGenerator->generate($coreConfigData); |
|
1304 | ||
1305 | // query whether or not, the configuration value on 'websites' level |
|
1306 | if (isset($this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE])) { |
|
1307 | return $this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE]; |
|
1308 | } |
|
1309 | } |
|
1310 | } |
|
1311 | } |
|
1312 | ||
1313 | // replace scope with 'default' and scope ID '0' |
|
1314 | $coreConfigData = array_merge( |
|
1315 | $coreConfigData, |
|
1316 | array( |
|
1317 | MemberNames::SCOPE => ScopeKeys::SCOPE_DEFAULT, |
|
1318 | MemberNames::SCOPE_ID => 0 |
|
1319 | ) |
|
1320 | ); |
|
1321 | ||
1322 | // generate the UID from the passed data, merged with the 'default' scope and ID 0 |
|
1323 | $uniqueIdentifier = $this->coreConfigDataUidGenerator->generate($coreConfigData); |
|
1324 | ||
1325 | // query whether or not, the configuration value on 'default' level |
|
1326 | if (isset($this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE])) { |
|
1327 | return $this->coreConfigData[$uniqueIdentifier][MemberNames::VALUE]; |
|
1328 | } |
|
1329 | ||
1330 | // if not, return the passed default value |
|
1331 | if ($default !== null) { |
|
1332 | return $default; |
|
1333 | } |
|
1334 | ||
1335 | // throw an exception if no value can be found |
|
1336 | // in the Magento configuration |
|
1337 | throw new \Exception( |
|
1338 | sprintf( |
|
1339 | 'Can\'t find a value for configuration "%s-%s-%d" in "core_config_data"', |
|
1340 | $path, |
|
1341 | $scope, |
|
1342 | $scopeId |
|
1343 | ) |
|
1344 | ); |
|
1345 | } |
|
1346 | ||
1347 | /** |
|
1348 | * Resolve the original column name for the passed one. |