Beispiel #1
0
 public static function findPathForSetting(&$settings, $settingPath, $basicScope = false)
 {
     $searchResults = ArrayTools::TraverseTreeWithPath($settings, $settingPath);
     if (empty($searchResults)) {
         LogCLI::MessageResult(LogCLI::YELLOW . 'Sorry, no settings found for: ' . LogCLI::BLUE . $settingPath . LogCLI::RESET, 0, LogCLI::INFO);
         return false;
     } else {
         if (count($searchResults['all']) > 1) {
             LogCLI::MessageResult(LogCLI::YELLOW . 'Multiple settings found for: ' . LogCLI::BLUE . $settingPath . LogCLI::RESET, 4, LogCLI::INFO);
         }
         LogCLI::MessageResult(LogCLI::GREEN . 'Best match: ' . LogCLI::BLUE . $searchResults['best'] . LogCLI::RESET, 0, LogCLI::INFO);
         $path = $searchResults['best'];
         if ($basicScope !== false) {
             if (($pos = strpos($path, $basicScope)) !== false && $pos === 0) {
                 $path = StringTools::DropLastBit($path, -1);
             }
         }
         $parent = ArrayTools::accessArrayElementByPath($settings, StringTools::DropLastBit($searchResults['best']));
         if (isset($parent['iterative'])) {
             $path = StringTools::DropLastBit($path, -1);
         }
         LogCLI::MessageResult('Fixed path: ' . LogCLI::YELLOW . $searchResults['best'] . ' => ' . LogCLI::BLUE . $path . LogCLI::RESET, 6, LogCLI::INFO);
         return $path;
     }
 }