Beispiel #1
0
 public function mergeDefinitionsDB(array $settingsArray, array &$definitions, $applyDefaults = false, $path = 'defaults')
 {
     if ($path !== null) {
         $definitionsPaths = ArrayTools::TraverseTree($settingsArray, $path);
         //var_dump($settingsArray);
         //            $mergeNotReplace = ArrayTools::TraverseTree($settingsArray, 'custom');
         //var_dump($mergeNotReplace);
     } else {
         // TODO
     }
     /*
     if($mergeNotReplace)
     {
         foreach($mergeNotReplace as $mergePath)
         {
             LogCLI::MessageResult('Merging definitions in storage: '.LogCLI::BLUE.$mergePath.LogCLI::RESET, 5, LogCLI::INFO);
             var_dump(ArrayTools::accessArrayElementByPath($settingsArray, $mergePath));
             var_dump($definitions);
             // let's copy all the definitions and merge them, overriding any previously set settings in this instance
             ArrayTools::mergeArrayElementByPath(&$definitions, $mergePath, ArrayTools::accessArrayElementByPath($settingsArray, $mergePath), 0, true); // no override
             var_dump($definitions);
         }
     }
     */
     if ($definitionsPaths) {
         foreach ($definitionsPaths as $definitionsPath) {
             LogCLI::MessageResult('Copying to definitions storage: ' . LogCLI::BLUE . $definitionsPath . LogCLI::RESET, 5, LogCLI::INFO);
             // let's copy all the definitions and merge them, overriding any previously set settings in this instance
             ArrayTools::mergeArrayElementByPath($definitions, $definitionsPath, ArrayTools::accessArrayElementByPath($settingsArray, $definitionsPath), 0);
             // remove the defaults, they are not needed anymore, we have them in a separated array
             $this->removeByPath($definitionsPath);
             // optionally apply them to all elements
             if ($applyDefaults === true) {
                 $this->applyDefaults($this->DB, $definitions, $definitionsPath, $path, false, true);
             }
         }
     }
 }