@@ -77,6 +77,13 @@ public function export()
7777 return $ exports ;
7878 }
7979
80+ public function exportSettings ()
81+ {
82+ return $ this ->settings ()->get ()->map (function ($ setting ) {
83+ return $ setting ->export ();
84+ });
85+ }
86+
8087 public function syncAssets ($ assets )
8188 {
8289 $ assetKeys = [];
@@ -135,14 +142,16 @@ public function addSettings($setting, $config)
135142 {
136143 $ exists = $ this ->settings ()->where ('setting ' , $ setting )->exists ();
137144 if ($ exists ) {
138- throw ValidationException::withMessages (['* ' => 'Setting already exists in bundle ' ]);
145+ $ this ->settings ()->where ('setting ' , $ setting )->update ([
146+ 'config ' => $ config ,
147+ ]);
148+ } else {
149+ BundleSetting::create ([
150+ 'bundle_id ' => $ this ->id ,
151+ 'setting ' => $ setting ,
152+ 'config ' => $ config ,
153+ ]);
139154 }
140-
141- BundleSetting::create ([
142- 'bundle_id ' => $ this ->id ,
143- 'setting ' => $ setting ,
144- 'config ' => $ config ,
145- ]);
146155 }
147156
148157 public function addAssetToBundles (ProcessMakerModel $ asset )
@@ -204,6 +213,19 @@ public function savePayloadsToFile(array $payloads)
204213 }
205214 }
206215
216+ public function installSettings ($ settings )
217+ {
218+ $ newSettingsKeys = collect ($ settings )->pluck ('setting ' )->toArray ();
219+
220+ $ this ->settings ()
221+ ->whereNotIn ('setting ' , $ newSettingsKeys )
222+ ->delete ();
223+
224+ foreach ($ settings as $ setting ) {
225+ $ this ->addSettings ($ setting ['setting ' ], $ setting ['config ' ]);
226+ }
227+ }
228+
207229 public function install (array $ payloads , $ mode , $ logger = null )
208230 {
209231 if ($ logger === null ) {
0 commit comments