Skip to content

Commit

Permalink
Merge pull request #22 from AleksandrsKondratjevs/issue-3361
Browse files Browse the repository at this point in the history
Add check for scandipwa version in dependencies
  • Loading branch information
carinadues authored Sep 24, 2021
2 parents 5853966 + db0f3bf commit 43d2822
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Block/Page/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function getPackageJsonData() {
$pathToTheme = substr($pathToTheme, 0, -7) . self::PACKAGE_JSON_FILE;

if (file_exists($pathToTheme)) {
$packageData = json_decode(file_get_contents($pathToTheme));
$this->scandiPWAPackgeVersion = $packageData->version ?? false;
$packageData = json_decode(file_get_contents($pathToTheme), true);
$this->scandiPWAPackgeVersion = $this->getScandiPWAFromPackageData($packageData);
} else {
$this->scandiPWAPackgeVersion = false;
}
Expand Down Expand Up @@ -112,6 +112,18 @@ public function getScandiPWADirectoryPath() {
return $themeDirectoryPath;
}

/**
* @param $data
* @return string|false
*/
public function getScandiPWAFromPackageData($data) {
if (isset($data['dependencies']['@scandipwa/scandipwa'])) {
return $data['dependencies']['@scandipwa/scandipwa'];
}

return $data['version'] ?? false;
}

/**
* @return string|false
*/
Expand Down

0 comments on commit 43d2822

Please sign in to comment.