public function add($name, Closure $callback = null)
    {
        try
        {
            $path = $this->finder->find($name);

            if (isset($this->assets[$path]))
            {
                $asset = $this->assets[$path];
            }
            else
            {
                $asset = $this->factory->get('asset')->make($path);

                $asset->isRemote() and $asset->raw();
            }

            is_callable($callback) and call_user_func($callback, $asset);

            return $this->assets[$path] = $asset;
        }
        catch (AssetNotFoundException $e)
        {
            $this->getLogger()->error(sprintf('Asset "%s" could not be found in "%s"', $name, $this->path));

            return $this->factory->get('asset')->make(null);
        }
    }
public function add($name, Closure $callback = null)
    {
        try
        {
            $path = $this->finder->find($name);

            if (isset($this->assets[$path]))
            {
                $asset = $this->assets[$path];
            }
            else
            {
                $asset = $this->factory->get('asset')->make($path);

                $asset->isRemote() and $asset->raw();
            }

            is_callable($callback) and call_user_func($callback, $asset);

            return $this->assets[$path] = $asset;
        }
        catch (AssetNotFoundException $e)
        {
            $this->getLogger()->error(sprintf('Asset "%s" could not be found in "%s"', $name, $this->path));

            return $this->factory->get('asset')->make(null);
        }
    }
public function add ( $ name , Closure $ callback = null ) { try { $ path = $ this -> finder -> find ( $ name ) ; if ( isset ( $ this -> assets [ $ path ] ) ) { $ asset = $ this -> assets [ $ path ] ; } else { $ asset = $ this -> factory -> get ( 'asset' ) -> make ( $ path ) ; $ asset -> isRemote ( ) and $ asset -> raw ( ) ; } is_callable ( $ callback ) and call_user_func ( $ callback , $ asset ) ; return $ this -> assets [ $ path ] = $ asset ; } catch ( AssetNotFoundException $ e ) { $ this -> getLogger ( ) -> error ( sprintf ( 'Asset "%s" could not be found in "%s"' , $ name , $ this -> path ) ) ; return $ this -> factory -> get ( 'asset' ) -> make ( null ) ; } }
Find and add an asset to the directory.

@param  string  $name
@param  \Closure  $callback
@return \Basset\Asset
Find and add an asset to the directory .