From 782bc10ad86794110b43d2e30359c5f1c3ab658a Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 7 Feb 2014 13:43:48 +0200 Subject: [PATCH] rename from 'sytemConfig' to 'config' in defaults folder --- application/Espo/Core/Utils/Config.php | 140 +++++++++--------- .../defaults/{systemConfig.php => config.php} | 0 2 files changed, 70 insertions(+), 70 deletions(-) rename application/Espo/Core/defaults/{systemConfig.php => config.php} (100%) diff --git a/application/Espo/Core/Utils/Config.php b/application/Espo/Core/Utils/Config.php index d49ef7613e..66e7f42cb4 100644 --- a/application/Espo/Core/Utils/Config.php +++ b/application/Espo/Core/Utils/Config.php @@ -5,28 +5,28 @@ namespace Espo\Core\Utils; class Config { /** - * Path of system config file - * - * @access private - * @var string - */ - private $systemConfigPath = 'application/Espo/Core/defaults/systemConfig.php'; + * Path of default config file + * + * @access private + * @var string + */ + private $defaultConfigPath = 'application/Espo/Core/defaults/config.php'; /** - * Array of admin items - * - * @access protected - * @var array - */ - protected $adminItems= array(); + * Array of admin items + * + * @access protected + * @var array + */ + protected $adminItems = array(); /** - * Contains content of system config - * - * @access private - * @var string - */ + * Contains content of default config + * + * @access private + * @var string + */ private $lastConfigObj; private $fileManager; @@ -45,17 +45,17 @@ class Config /** - * Get an option from system config - * - * @param string $name - * @return string | array - */ + * Get an option from config + * + * @param string $name + * @return string | array + */ public function get($name) { $keys = explode('.', $name); $lastBranch = $this->getConfig(); - foreach($keys as $keyName) { + foreach ($keys as $keyName) { if (isset($lastBranch->$keyName) && is_object($lastBranch)) { $lastBranch = $lastBranch->$keyName; } else { @@ -68,20 +68,20 @@ class Config /** - * Set an option to the system config - * - * @param string $name - * @param string $value - * @return bool - */ + * Set an option to the config + * + * @param string $name + * @param string $value + * @return bool + */ public function set($name, $value='') { if (Json::isJSON($value)) { $value= Json::decode($value); } - $content= array($name => $value); - $status= $this->getFileManager()->mergeContentPHP($content, $this->get('configPath'), '', true); + $content = array($name => $value); + $status = $this->getFileManager()->mergeContentPHP($content, $this->get('configPath'), '', true); $this->getConfig(true); return $status; @@ -89,63 +89,63 @@ class Config /** - * Set options from array - * - * @param array $values - * @return bool - */ + * Set options from array + * + * @param array $values + * @return bool + */ public function setArray($values) { if (Json::isJSON($values)) { - $values= Json::decode($values); + $values = Json::decode($values); } if (!is_array($values)) { return false; } - $status= $this->getFileManager()->mergeContentPHP($values, $this->get('configPath'), '', true); + $status = $this->getFileManager()->mergeContentPHP($values, $this->get('configPath'), '', true); $this->getConfig(true); return $status; } /** - * Return an Object of all configs - * - * @return object - */ + * Return an Object of all configs + * + * @return object + */ function getConfig($reload=false) { if (!$reload && isset($this->lastConfigObj) && !empty($this->lastConfigObj)) { return $this->lastConfigObj; } - $systemConfig= $this->getFileManager()->getContent($this->systemConfigPath); + $defaultConfig = $this->getFileManager()->getContent($this->defaultConfigPath); - $config= $this->getFileManager()->getContent($systemConfig['configPath']); + $config = $this->getFileManager()->getContent($defaultConfig['configPath']); if (empty($config)) { - $GLOBALS['log']->add('FATAL', 'Check syntax or permission of your '.$systemConfig['configPath']); + $GLOBALS['log']->add('FATAL', 'Check syntax or permission of your '.$defaultConfig['configPath']); } - $this->lastConfigObj = Util::arrayToObject( Util::merge((array) $systemConfig, (array) $config) ); - $this->adminItems= $this->getRestrictItems(); + $this->lastConfigObj = Util::arrayToObject( Util::merge((array) $defaultConfig, (array) $config) ); + $this->adminItems = $this->getRestrictItems(); return $this->lastConfigObj; } /** - * Get JSON config acording to restrictions for a user - * - * @param $isAdmin - * @return object - */ + * Get JSON config acording to restrictions for a user + * + * @param $isAdmin + * @return object + */ public function getData($isAdmin=false, $encode=true) { $configObj = $this->getConfig(); - $restrictedConfig= $configObj; + $restrictedConfig = $configObj; foreach($this->getRestrictItems($isAdmin) as $name) { if (isset($restrictedConfig->$name)) { unset($restrictedConfig->$name); @@ -161,16 +161,16 @@ class Config /** - * Set JSON data acording to restrictions for a user - * - * @param $isAdmin - * @return bool - */ + * Set JSON data acording to restrictions for a user + * + * @param $isAdmin + * @return bool + */ //HERE public function setData($data, $isAdmin=false) { - $restrictItems= $this->getRestrictItems($isAdmin); + $restrictItems = $this->getRestrictItems($isAdmin); $values= array(); foreach($data as $key => $item) { @@ -183,11 +183,11 @@ class Config } /** - * Get admin items - * - * @return object - */ - protected function getRestrictItems($onlySystemItems=false) + * Get admin items + * + * @return object + */ + protected function getRestrictItems($onlySystemItems = false) { if ($onlySystemItems) { return ((array) $this->getConfig()->systemItems); @@ -202,12 +202,12 @@ class Config /** - * Check if an item is allowed to get and save - * - * @param $name - * @param $isAdmin - * @return bool - */ + * Check if an item is allowed to get and save + * + * @param $name + * @param $isAdmin + * @return bool + */ protected function isAllowed($name, $isAdmin=false) { if (in_array($name, $this->getRestrictItems($isAdmin))) { diff --git a/application/Espo/Core/defaults/systemConfig.php b/application/Espo/Core/defaults/config.php similarity index 100% rename from application/Espo/Core/defaults/systemConfig.php rename to application/Espo/Core/defaults/config.php