From 4bda494c6bb9c0d06004fd43ab1641bf9b4648e3 Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Mon, 21 Dec 2020 11:30:44 -0500 Subject: [PATCH] Add helpers kvp() and kvp_save() (#966) --- app/helpers.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/app/helpers.php b/app/helpers.php index 9a598c800..d0de5b95f 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,6 +1,7 @@ get($key, $default); + } catch (Exception $e) { + return $default; + } + + return $value; + } +} + +/* + * Shortcut for retrieving a KVP + */ +if (!function_exists('kvp_save')) { + /** + * Read a setting from the KVP repository + * + * @param string $key + * @param string $value + * + * @return mixed|null + */ + function kvp_save(string $key, string $value) + { + /** @var KvpRepository $kvpRepo */ + $kvpRepo = app(KvpRepository::class); + $kvpRepo->save($key, $value); + } +} + /* * Wrap the asset URL in the publicBaseUrl that's been * set