예제 #1
0
 /**
  * Returns the actual path to an asset based on the key provided,
  * by resolving to the correct location in the correct theme.
  *
  * @param  string  $key
  * @return string
  * @throws \InvalidArgumentException
  */
 public function getPath($key)
 {
     list($section, $relativePath, $extension) = with(new NamespacedItemResolver())->parseKey($key);
     // If we have a section, let's check if it's a namespace
     // or a package section
     if (isset($section)) {
         // Namespace
         if (in_array($section, $this->viewFinder->getNamespaces())) {
             $paths = $this->themeBag->getCascadedNamespaceAssetPaths($section);
         } else {
             $paths = $this->themeBag->getCascadedPackageAssetPaths($section);
         }
     } else {
         $paths = $this->themeBag->getCascadedAssetPaths();
     }
     // Now loop through the available paths to see if the asset
     // exists. If it does, we'll return the file.
     foreach ($paths as $path) {
         $file = rtrim($path, '/') . '/' . $relativePath . '.' . $extension;
         if ($this->themeBag->getFilesystem()->exists($file)) {
             return $file;
         }
     }
     return $file;
 }