Exemplo n.º 1
0
 /**
  * Register a package with the environment.
  * 
  * @param  string  $package
  * @param  string  $namespace
  * @return void
  */
 public function package($package, $namespace = null)
 {
     if (is_null($namespace)) {
         list($vendor, $namespace) = explode('/', $package);
     }
     $this->finder->addNamespace($namespace, $package);
 }
Exemplo n.º 2
0
 /**
  * Change the working directory.
  *
  * @param  string  $path
  * @param  \Closure  $callback
  * @return \Basset\Collection|\Basset\Directory
  */
 public function directory($path, Closure $callback = null)
 {
     try {
         $path = $this->finder->setWorkingDirectory($path);
         $this->directories[$path] = new Directory($this->factory, $this->finder, $path);
         // Once we've set the working directory we'll fire the callback so that any added assets
         // are relative to the working directory. After the callback we can revert the working
         // directory.
         is_callable($callback) and call_user_func($callback, $this->directories[$path]);
         $this->finder->resetWorkingDirectory();
         return $this->directories[$path];
     } catch (DirectoryNotFoundException $e) {
         $this->getLogger()->error(sprintf('Directory "%s" could not be found in "%s"', $path, $this->path));
         return new Directory($this->factory, $this->finder, null);
     }
 }