Find and add an asset to the directory.

@param  string  $name
@param  \Closure  $callback
@return \Basset\Asset
13198
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);
        }
    }
304951
public function addCallback(string $name, $callback)
    {
        if (!is_object($callback)) {
            throw new \InvalidArgumentException('Given callback must be an object');
        }

        $this->callbacks[$name] = $callback;
    }
971347
private function withOptionReference($name, $callback)
    {
        if (!$this->options) {
            $this->options = new ArrayObject();
        }

        return $this->withVariableReference($this->options, $name, $callback);
    }
485588
public function map(Closure $callback)
    {
        return new self(array_map($callback, $this->items, array_keys($this->items)));
    }
787266
public function addAsset($name, $path)
    {
        if (!is_file($path)) {
            throw new \RuntimeException('The asset file "' . $path . '" does not exist.');
        }
        $this->assets[$name] = $path;
    }
462331
public function addResolver(string $name, callable $callback)
    {
        //if it's a closure, they meant to bind the callback
        if ($callback instanceof Closure) {
            //so there's no scope
            $callback = $callback->bindTo($this, get_class($this));
        }

        $this->getResolverHandler()->register($name, $callback);

        return $this;
    }
827410
public function withAttr($name, $callback = null)
    {
        if (is_array($name)) {
            $this->options['with_attr'] = $name;
        } else {
            $this->options['with_attr'][$name] = $callback;
        }

        return $this;
    }
423741
protected function buildBasic($name, Closure $callback = null): void
    {
        if ($name instanceof Closure) {
            $callback = $name;
            $name = null;
        }

        ! empty($name) && $this->legend($name);

        $callback($this);
    }
1373117
public function build($name = null, array $attributes = [], $callback = null)
    {
        if (!isset($attributes['response-container'])) {
            array_set($attributes, 'response-container', 'test-response');
        }
        if (!isset($attributes['form-container'])) {
            array_set($attributes, 'form-container', 'tester-form');
        }
        $script    = is_null($name) ? 'round' : $name;
        $container = app('antares.asset')->container('antares/foundation::scripts');
        $container->inlineScript($script, $this->generateScripts($attributes));
        if ($callback instanceof Closure) {
            call_user_func($callback, $container);
        }
    }
962586
public function extend($name, Closure $callback)
    {
        $this->parsers[Str::camel($name)] = Str::title($name);

        return parent::extend($name, $callback);
    }
1248341
public static function make($name, Closure $callback = null)
    {
        $menu = new self($name);
        if ( ! is_null($callback)) {
            call_user_func($callback, $menu);
        }

        return $menu;
    }
905850
public function addFilter($callback, $name = null)
    {
        $tuple = $this->createFilterTuple(func_get_args());

        $this->filters[] = $tuple;

        $this->handleChangedParameters();

        return $this;
    }
713363
public function mapSurname(Closure $callback)
    {
        if (!static::$surnamesHandle instanceof SplFileObject) {
            static::$surnamesHandle = $this->openFile($this->path.'/surnames');
        }

        $this->traversing($this->getGenerator([static::$surnamesHandle]), $callback);
    }
729840
public function of(string $name, callable $callback = null): BuilderContract
    {
        if (! isset($this->names[$name])) {
            $this->names[$name] = $this->make($callback);
            $this->names[$name]->name = $name;
        }

        return $this->names[$name];
    }
878895
public function group($name, Closure $callback = null)
    {
        if ($this->groups->has($name)) {
            $group = $this->groups->get($name);
        } else {
            $group = $this->container->make('Maatwebsite\Sidebar\Group');
            $group->name($name);
        }

        $this->call($callback, $group);

        $this->addGroup($group);

        return $group;
    }
795764
public function callback(string $name, callable $callback): self
    {
        $this->callbacks[$name] = $callback;
        return $this;
    }
957233
public function getAssetID($name)
    {
        $list = $this->getAssetList();

        $list_json = json_decode($list, true);

        foreach ($list_json as $asset)
        {
            if ($asset['name'] == $name)
            {
                return $asset['id'];
            }
        }
        throw new \Exception('No asset found by name');
    }