Skip to content

Commit 88a10be

Browse files
committed
Fixes storing project with new repo
1 parent e3e331d commit 88a10be

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/Foundation/Console/ProjectSetCommand.php

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,22 @@ public function handle()
6969
protected function storeProjectDetails($result)
7070
{
7171
// Save project locally
72-
if (class_exists(\System\Models\Parameter::class)) {
73-
\System\Models\Parameter::set([
74-
'system::project.id' => $result['id'],
75-
'system::project.key' => $result['project_id'],
76-
'system::project.name' => $result['name'],
77-
'system::project.owner' => $result['owner'],
78-
'system::project.is_active' => $result['is_active']
79-
]);
80-
}
81-
else {
82-
if (!is_dir($cmsStorePath = storage_path('cms'))) {
83-
mkdir($cmsStorePath);
72+
try {
73+
if (class_exists(\System\Models\Parameter::class)) {
74+
\System\Models\Parameter::set([
75+
'system::project.id' => $result['id'],
76+
'system::project.key' => $result['project_id'],
77+
'system::project.name' => $result['name'],
78+
'system::project.owner' => $result['owner'],
79+
'system::project.is_active' => $result['is_active']
80+
]);
81+
}
82+
else {
83+
$this->storeProjectDetailsLocally($result);
8484
}
85-
86-
$this->injectJsonToFile(storage_path('cms/project.json'), [
87-
'project' => $result['project_id']
88-
]);
85+
}
86+
catch (Exception $ex) {
87+
$this->storeProjectDetailsLocally($result);
8988
}
9089

9190
// Save authentication token
@@ -96,6 +95,20 @@ protected function storeProjectDetails($result)
9695
);
9796
}
9897

98+
/**
99+
* storeProjectDetailsLocally instead
100+
*/
101+
protected function storeProjectDetailsLocally($result)
102+
{
103+
if (!is_dir($cmsStorePath = storage_path('cms'))) {
104+
mkdir($cmsStorePath);
105+
}
106+
107+
$this->injectJsonToFile(storage_path('cms/project.json'), [
108+
'project' => $result['project_id']
109+
]);
110+
}
111+
99112
/**
100113
* requestServerData contacts the update server for a response.
101114
* @param string $uri Gateway API URI

0 commit comments

Comments
 (0)