Attach item to current widget.

@param  string  $id
@param  string|\Closure  $location
@param  \Closure|null  $callback

@return mixed
547586
protected function addItem(string $id, $location = 'parent', $callback = null): ?Fluent
    {
        if ($location instanceof Closure) {
            $callback = $location;
            $location = 'parent';
        }

        $item = $this->nesty->add($id, $location ?: 'parent');

        if ($callback instanceof Closure) {
            $callback($item);
        }

        return $item;
    }
1327496
public function set($id, callable $callback)
    {
        if ($this->has($id)) {
            throw new Exception\AlreadyExistsException;
        }
        $this->callbacks[$id] = $callback;
    }
951683
public function insert ($id, $bind, $callerMethod) 
    {
        $timer = $this->profiler->openTimer(__METHOD__, $bind, $callerMethod);
        $request = $this->dataAdapter->getInsertRequest($id, $bind);
        $request->send();
        $request->fetch();
        $this->profiler->finishTimer($timer);
        
        return $request->getResult();
    }
370864
public final function hook($hookId, callable $callback = null)
	{
		if (null === $callback) {
			//触发
			if (isset($this->hooks[$hookId])) {
				return ($this->hooks[$hookId])($this);
			}
		} else {
			//绑定
			$id = 1;
			while ($hookId > 0) {
				if ($hookId & 1 == 1) {
					$this->hooks[$id] = $callback;
				}
				$id *= 2;
				$hookId >>= 1;
			}
		}
	}
441946
public function bind(string $id, $concrete = null)
    {
        if ($concrete === null) {
            $concrete = $id;
        }

        if (! $concrete instanceof Closure) {
            $concrete = function ($container, $parameters = []) use ($id, $concrete) {
                if ($id === $concrete) {
                    return $container->resolve($concrete, $parameters);
                }
                return $container->make($concrete, $parameters);
            };
        }

        $this->bindings[$id] = $concrete;
    }
1302922
public function container($container = null, Closure $callback = null)
    {
        $container = is_null($container) ? $this->defaultContainer : $container;

        if (!isset($this->containers[$container])) {
            $this->addContainer(
                $container,
                $this->getContainerTypes($container),
                $this->getContainerFormat($container),
                $this->getContainerFormats($container)
            );
        }

        if (is_callable($callback)) {
            $callback($this->containers[$container]);
        }

        return $this->containers[$container];
    }
582587
public function addInToolbar($element,$callback=NULL){
		$tb=$this->getToolbar();
		if($element instanceof BaseWidget){
			if($element->getIdentifier()===""){
				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
			}
		}
		if(isset($callback)){
			if(\is_callable($callback)){
				$callback($element);
			}
		}
		return $tb->addItem($element);
	}
140493
function (callback, id) {
        if (id === undefined && storeObjectId) {
          id = storeObjectId
        }
        getById(callback, 'stores', id)
      }
569868
public function register(string $id, callable $callback): self
    {
        Internal\Data\Addons::$registrations[$id] = $callback;
        return $this;
    }
747815
function find(id, callback) {
        var Model, request;

        Model = this;
        request = {
            action : 'findOne',
            model : Model,
            params : {
                id : id
            }
        };
        this.storage.findOne(request, function findOneCallback(data) {
            if (callback) {
                callback(data);
            }
        });
        return this;
    }
764601
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);
        }
    }
1089063
public function bindCallback($callback, $argument = null) {
        if ($callback instanceof Closure) {
            call_user_func_array($callback, [$this, $argument]);
        }

        return $this;
    }
788027
public function push($element, Closure $callback = null): self
    {
        $element = $this->createElement($element);

        if ($callback) {
            $callback($element);
        }

        parent::push($element);

        return $this;
    }
872232
public function with($selector, Closure $callback)
    {
        $browser = new static(
            $this->driver, new ElementResolver($this->driver, $this->resolver->format($selector))
        );

        if ($this->page) {
            $browser->onWithoutAssert($this->page);
        }

        if ($selector instanceof Component) {
            $browser->onComponent($selector, $this->resolver);
        }

        call_user_func($callback, $browser);

        return $this;
    }
249987
public function getLocation($id)
    {
        $url = $this->buildUrlByMethodName(
            'getGetLocationUrl',
            ['id' => $id]
        );

        return $this
            ->buildLocation(
                $this->resolveApiUrl($url)
            );
    }
1358620
public function add($id, $location = '#')
    {
        if ($location === '<' && count($keys = array_keys($this->items)) > 0) {
            return $this->addBefore($id, $keys[0]);
        } elseif (preg_match('/^(<|>|\^):(.+)$/', $location, $matches) && count($matches) >= 3) {
            return $this->pickTraverseFromMatchedExpression($id, $matches[1], $matches[2]);
        }
        return $this->addParent($id);
    }
1103186
@SuppressWarnings("unchecked")
  public <C extends CDACallback<T>> C one(String id, C callback) {
    return (C) Callbacks.subscribeAsync(baseQuery().one(id), callback, client);
  }