Register an "if" statement directive.

@param  string  $name
@param  callable  $callback
@return void
768905
public function if($name, callable $callback)
    {
        $this->conditions[$name] = $callback;

        $this->directive($name, function ($expression) use ($name) {
            return $expression !== ''
                    ? "<?php if (\Illuminate\Support\Facades\Blade::check('{$name}', {$expression})): ?>"
                    : "<?php if (\Illuminate\Support\Facades\Blade::check('{$name}')): ?>";
        });

        $this->directive('else'.$name, function ($expression) use ($name) {
            return $expression !== ''
                ? "<?php elseif (\Illuminate\Support\Facades\Blade::check('{$name}', {$expression})): ?>"
                : "<?php elseif (\Illuminate\Support\Facades\Blade::check('{$name}')): ?>";
        });

        $this->directive('end'.$name, function () {
            return '<?php endif; ?>';
        });
    }
627658
public function bind(string $name, callable $callback): self
    {
        $this->bindings[$name] = $callback;
        return $this;
    }
470633
public function withAttr($name, $callback = null)
    {
        $this->each(function ($model) use ($name, $callback) {
            /** @var Model $model */
            $model && $model->withAttribute($name, $callback);
        });

        return $this;
    }
1179
public function registerHelper($name, $helper = false)
    {
        if (is_array($name)) {
            foreach ($name as $n => $helper) {
                $this->registerHelper($n, $helper);
            }
        } elseif (is_object($name)) {
            $this->registerJavascriptObject('helper', $this->wrapHelperObject($name));
        } elseif ($helper === false) {
            $this->registerJavascriptObject('helper', $name);
        } elseif (is_callable($helper)) {
            $this->registerJavascriptFunction('helper', $name, $this->wrapHelperCallable($name, $helper));
        } else {
            $this->registerJavascriptFunction('helper', $name, $helper);
        }
    }
279715
public function addListener($name, callable $callback) {
        if(!array_key_exists($name, $this->registered_events)) {
            $this->registered_events[$name] = [];
        }

        $this->registered_events[$name][] = $callback;
    }
175805
public function unless($name, callable $callback, callable $default = null, array $context = [])
    {
        if ($this->isInactive($name, $context)) {
            return $callback($this->params($name), $context);
        } elseif ($default) {
            return $default($this->params($name), $context);
        }

        return $this;
    }
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;
    }
1054081
public function addRule(string $name, callable $callback, string $message = null): self
    {
        if ($message === null) {
            $message = static::ERROR_DEFAULT;
        }

        static::assertRuleCallback($callback);

        static::$_rules[$name] = $callback;
        static::$_ruleMessages[$name] = $message;

        return $this;
    }
617198
public function register($name, $callback)
    {
        if (! isset($this->registered_menus[$name])) {
            $this->registered_menus[$name] = [];
        }

        $this->registered_menus[$name][] = $callback;

        return $this;
    }
243000
public function notifyError($name, $message, callable $callback = null)
    {
        $report = Report::fromNamedError($this->config, $name, $message);

        $this->notify($report, $callback);
    }
762522
public function register($name, Closure $callback)
    {
        $this->checkCallbackName($name);

        $this->callbacks[$name] = $callback;

        return $this;
    }
11717
public function registerFilter($name, $callback, $wiringSchema = null)
    {
        if (!preg_match('#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#', $name)) {
            throw new InvalidArgumentException(
                "Invalid filter name given: '$name'. For filter names apply the same rules as for function names in PHP."
            );
        }
        if (isset($this->filters[$name])) {
            throw new InvalidArgumentException("Filter with name '$name' was already registered.");
        }
        if (!is_callable($callback, true)) {
            throw new InvalidArgumentException("Callback given for filter '$name' is not callable.");
        }
        $this->filters[$name] = [$callback, $this->translateWiringSchema($wiringSchema)];
    }
95916
public function javascript($name, Closure $callback = null)
    {
        return $this->add($name, function($asset) use ($callback)
        {
            $asset->setGroup('javascripts');

            is_callable($callback) and call_user_func($callback, $asset);
        });
    }
483334
public function filter($name, $callback)
	{
		$this->events->listen('router.filter: '.$name, $this->parseFilter($callback));
	}
751665
public static function addRule($name, $callback, $message = 'error param')
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('param $callback must can callable');
        }
        self::$errorTip[strtolower($name)] = $message;
        static::$rules[$name] = $callback;
    }
572706
public function register(string $name, $callback) : Event
    {
        if (is_null($name)) {
            throw new \RuntimeException(sprintf('Event name cannot be empty in %s', __FUNCTION__));
        }

        if (is_null($callback)) {
            throw new \RuntimeException(sprintf('Empty parameter passed as callback in %s function', __FUNCTION__));
        }

        if (!isset($this->events[$name])) {
            $this->events[$name] = [];
        }

        if (!in_array($callback, $this->events[$name])) {
            $this->events[$name][] = $callback;
        }

        return $this;
    }
285708
public function addTask($name, $callback)
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('Task should be a callback.');
        }

        $this->tasks[$name] = $callback;

        return $this;
    }