예제 #1
0
파일: Resolve.php 프로젝트: JoeHorn/Core
 /**
  * The entry method.
  *
  * @return  int
  */
 public function main()
 {
     $exists = true;
     $unfold = false;
     $tree = false;
     $verbose = Console::isDirect(STDOUT);
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'E':
                 $exists = false;
                 break;
             case 'u':
                 $unfold = true;
                 break;
             case 't':
                 $tree = true;
                 break;
             case 'V':
                 $verbose = false;
                 break;
             case 'h':
             case '?':
                 return $this->usage();
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
         }
     }
     $this->parser->listInputs($path);
     if (null === $path) {
         return $this->usage();
     }
     if (true === $tree) {
         $protocol = Core::getProtocol();
         $foo = substr($path, 0, 6);
         if ('hoa://' !== $foo) {
             return;
         }
         $path = substr($path, 6);
         $current = $protocol;
         foreach (explode('/', $path) as $component) {
             if (!isset($current[$component])) {
                 break;
             }
             $current = $current[$component];
         }
         echo $current;
         return;
     }
     if (true === $verbose) {
         echo Console\Chrome\Text::colorize($path, 'foreground(yellow)'), ' is equivalent to:', "\n";
     }
     $resolved = resolve($path, $exists, $unfold);
     foreach ((array) $resolved as $r) {
         echo $r, "\n";
     }
     return;
 }
예제 #2
0
 /**
  * Get the real path of the given URL.
  * Could return false if the path cannot be reached.
  *
  * @param   string  $path      Path (or URL).
  * @param   bool    $exists    If true, try to find the first that exists,
  * @return  mixed
  */
 public static function realPath($path, $exists = true)
 {
     return Core::getProtocol()->resolve($path, $exists);
 }