Esempio n. 1
0
File: Context.php Progetto: chh/pipe
 function resolve($path)
 {
     # Skip the load path if the path starts with `./`
     if (preg_match('{^\\.(/|\\\\)}', $path)) {
         $path = dirname($this->path) . DIRECTORY_SEPARATOR . $path;
     }
     # When resolving a directory either look for a file named
     # "$dir/index.$ext" or return the path to the directory (e.g.
     # for "require_tree").
     if (is_dir($path)) {
         $index = Path::join(array($path, "index{$this->getExtension()}"));
         if (file_exists($index)) {
             $path = $index;
         } else {
             $pathinfo = new PathInfo($path);
             if ($pathinfo->isAbsolute()) {
                 return $path;
             }
             return $this->environment->loadPaths->find($path);
         }
     }
     $pathinfo = new PathInfo($path);
     if ($pathinfo->isAbsolute()) {
         return $path;
     }
     return $this->environment->loadPaths->find($path);
 }
Esempio n. 2
0
 /**
  * Finds the logical path in the stack of load paths
  * and returns the Asset.
  *
  * Example:
  *
  *     <?php
  *     // Get the bundled application.js
  *     $asset = $env->find('application.js', ['bundled' => true]);
  *
  * @param string $logicalPath Path relative to the load path.
  * @param array $options
  *
  * @return Asset
  */
 function find($logicalPath, $options = array())
 {
     $path = new FileUtils\PathInfo($logicalPath);
     if ($path->isAbsolute()) {
         $realPath = $logicalPath;
     } else {
         $realPath = $this->loadPaths->find($logicalPath);
     }
     if (!is_file($realPath)) {
         return;
     }
     if (null === $realPath) {
         return;
     }
     if (@$options["bundled"]) {
         $asset = new BundledAsset($this, $realPath, $logicalPath);
     } else {
         $asset = new ProcessedAsset($this, $realPath, $logicalPath);
     }
     return $asset;
 }