protected function applyDefaults(array &$setting, array &$defaultsDefinitions, $path, $nameOfObjectToApply = 'defaults', $directDefinition = false, $applyToAll = false) { if ($applyToAll === false) { $child = StringTools::ReturnLastBit($path); $parent = StringTools::DropLastBit($path); } else { $parent = $path; } $parentConfig = ArrayTools::accessArrayElementByPath($setting, $parent); if ($directDefinition === false) { $thisDefault = ArrayTools::accessArrayElementByPath($defaultsDefinitions, $parent); } else { $thisDefault =& $defaultsDefinitions; } if ($nameOfObjectToApply === null) { $defaults =& $thisDefault; } elseif (!isset($thisDefault[$nameOfObjectToApply])) { return false; } else { $defaults = $thisDefault[$nameOfObjectToApply]; } //var_dump($thisDefault); if ($applyToAll === false) { $config =& $parentConfig[$child]; if (is_numeric($child)) { LogCLI::MessageResult('Applying defaults to object ' . LogCLI::GREEN . $parent . '/' . LogCLI::YELLOW . $child . LogCLI::RESET, 6, LogCLI::INFO); // this will not override any configs, only merge in the ones that were not set $config = ArrayTools::MergeArrays($defaults, $config); } } else { foreach ($parentConfig as $child => &$config) { if (is_numeric($child)) { LogCLI::MessageResult('Applying defaults to object ' . LogCLI::GREEN . $parent . '/' . LogCLI::YELLOW . $child . LogCLI::RESET, 6, LogCLI::INFO); // this will not override any configs, only merge in the ones that were not set $config = ArrayTools::MergeArrays($defaults, $config); } } } // finally replace the array element ArrayTools::replaceArrayElementByPath($this->DB, $parent, $parentConfig); }
public function returnSettingsList($scope = false) { $this->listSettings($scope); //var_dump($this->settingsList); //var_dump($this->pathsList); $settingsInPaths = array(); foreach ($this->pathsList as $path) { $scope = StringTools::ReturnLastBit($path); if (isset($this->settingsList[$scope])) { ArrayTools::mergeArrayElementByPath($settingsInPaths, $path, $this->settingsList[$scope]); //var_dump($this->settingsList[$scope]); } else { LogCLI::Warning('The specification for the stem ' . LogCLI::GREEN . $scope . LogCLI::YELLOW . ' is missing in the parser class.'); //ArrayTools::mergeArrayElementByPath(&$settingsInPaths, $path, $this->settingsList); } } //var_dump($settingsInPaths); return $settingsInPaths; //return $this->settingsList; //return ArrayTools::GetMultiDimentionalElements(); }