2020-04-22 22:48:56 +03:00
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
2018-01-15 10:57:17 +03:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2020-03-11 12:10:59 +03:00
|
|
|
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
|
2018-01-15 10:57:17 +03:00
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.3.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/**
|
2021-10-23 14:04:15 +03:00
|
|
|
* Get / set the specified config value.
|
2018-01-15 10:57:17 +03:00
|
|
|
*
|
2021-10-23 14:04:15 +03:00
|
|
|
* Example "Get":
|
|
|
|
*
|
|
|
|
* config('version', '1.0.0');
|
|
|
|
*
|
|
|
|
* Example "Set":
|
|
|
|
*
|
2021-10-23 14:06:41 +03:00
|
|
|
* config(['version' => '1.0.0']);
|
2021-10-23 14:04:15 +03:00
|
|
|
*
|
|
|
|
* @param array|string $key Configuration key.
|
2021-10-23 13:59:39 +03:00
|
|
|
* @param mixed $default Default value in case the requested config has no value.
|
2018-01-15 10:57:17 +03:00
|
|
|
*
|
2021-10-23 14:04:15 +03:00
|
|
|
* @return mixed|NULL Returns the configuration value or NULL if setting the configuration key.
|
2021-10-23 14:06:41 +03:00
|
|
|
*
|
|
|
|
* @throws InvalidArgumentException
|
2018-01-15 10:57:17 +03:00
|
|
|
*/
|
2021-10-23 13:59:39 +03:00
|
|
|
function config($key, $default = NULL)
|
2018-01-23 12:08:37 +03:00
|
|
|
{
|
2021-10-23 14:04:15 +03:00
|
|
|
/** @var EA_Controller $CI */
|
2020-12-02 23:10:11 +03:00
|
|
|
$CI = &get_instance();
|
2018-01-15 10:57:17 +03:00
|
|
|
|
2021-10-23 14:04:15 +03:00
|
|
|
if (is_null($key))
|
|
|
|
{
|
2021-10-23 14:08:24 +03:00
|
|
|
throw new InvalidArgumentException('The $key argument cannot be empty.');
|
2021-10-23 14:04:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_array($key))
|
|
|
|
{
|
|
|
|
foreach ($key as $item => $value)
|
|
|
|
{
|
|
|
|
$CI->config->set_item($item, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-10-23 13:59:39 +03:00
|
|
|
$value = $CI->config->item($key);
|
|
|
|
|
|
|
|
return $value ?? $default;
|
2018-01-15 10:57:17 +03:00
|
|
|
}
|