Add an OPTIONS route with a callable and optionally a templatePath.

@param string      $url
@param callable    $callable
@param string|null $name
@param string|null $templatePath

@return $this
968357
public function options($url, $callable, $name = null, $templatePath = null)
    {
        $this->multiple([\Parable\Http\Request::METHOD_OPTIONS], $url, $callable, $name, $templatePath);
        return $this;
    }
886234
public function getUrl($name, $includeBasePath = true)
    {
        if ($this->callerNotSelfOrPathsProxy()) {
            Deprecated::method(3.3, 'Use UrlGenerator or Asset Packages instead.');
        }

        if (($name === 'canonical' || $name === 'canonicalurl') && isset($this->app['canonical'])) {
            if ($url = $this->app['canonical']->getUrl()) {
                return $url;
            }
        }

        if (!$this->requestInitialized && $this->app) {
            $this->initializeRequest($this->app, $this->requestObject);
        }

        if (!$this->configInitialized && in_array($name, ['theme', 'bolt', 'templates', 'templatespath'])) {
            $this->initializeConfig();
        }

        if (array_key_exists($name . 'url', $this->urls) && $name !== 'root') {
            return $this->urls[$name . 'url'];
        }
        if (! array_key_exists($name, $this->urls)) {
            throw new \InvalidArgumentException("Requested url $name is not available", 1);
        }

        $url = $this->urls[$name];

        if (!$includeBasePath || strpos($url, 'http') === 0 || strpos($url, '//') === 0) {
            return $url;
        }

        return $this->urlPrefix . $url;
    }
961528
public function registerTemplatePath($templateName, $path)
    {
        $this->templatesMap[(string) $templateName] = (string) $path;

        return $this;
    }
646040
public function setFormatOption($name, callable $handler)
    {
        if (in_array($name, static::$formatOptionsNames)) {
            return $this;
        }
        static::$formatOptionsNames[] = $name;
        static::$formatOptionsPlaceholders[] = '~' . count(static::$formatOptionsPlaceholders) . '~';
        static::$formatOptionsHandlers[] = $handler;
        return $this;
    }
140920
public function addCallable(string $name, callable $callable): self
    {
        $this->container[$name] = $callable;
        array_unshift($this->middleware, $name);

        return $this;
    }
61786
public function callback($callable, $description = null): ValidatorChain
    {
        $rule = Validator::rule('callback', [$callable]);
        if (null !== $description) {
            $rule->setDescription($description);
        }
        $this->addRule($rule);
        return $this;
    }
973969
public static function setPlaceholderFormatterDefinition($name, $callable)
    {
        if (!self::$formatters) {
            self::$formatters = self::initPlaceholderFormatters();
        }

        self::$formatters[$name] = $callable;
    }
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;
    }
659264
public function addFilter($name, $callable) {
        $filter = new RouteFilter($name, $callable);
        $this->getRoutesMatcher()->getFiltersMatcher()
            ->addFilter($filter);

        return $this;
    }
1064431
public void addTemplate( String templateName, URLTemplate template )
    {
        if ( templateName == null || templateName.length() == 0 )
        {
            throw new IllegalArgumentException( "Template name cannot be null or empty." );
        }

        if ( template == null )
        {
            throw new IllegalArgumentException( "URLTemplate cannot be null." );
        }

        _templates.put( templateName, template );
    }
213016
public function forEachNamed($name, callable $callable)
    {
        Types::assert(['string' => [$name]]);

        $name = strtolower($name);

        if (isset($this->headers[$name]))
        {
            foreach ($this->headers[$name] as $header)
            {
                $callable($header);
            }
        }
    }
1359840
public function hook($name, $callable, $priority = 10)
    {
        if (!isset($this->hooks[$name])) {
            $this->hooks[$name] = array(array());
        }
        if (is_callable($callable)) {
            $this->hooks[$name][(int) $priority][] = $callable;
        }
    }
192876
public function addTemplatesFolder($name, $path)
    {
        if (is_dir($path)) {
            $this->templateEngine->addFolder($name, $path);
        }
    }
5410
public function patch($url, $callable, $name = null, $templatePath = null)
    {
        $this->multiple([\Parable\Http\Request::METHOD_PATCH], $url, $callable, $name, $templatePath);
        return $this;
    }
734552
protected function callableWithRoute(callable $callable)/*# : bool */
    {
        /* @var EventCapableAbstract $route */
        $route = $this->result->getRoute();
        $param = ['result' => $this->result];
        if ($route->trigger(Route::EVENT_BEFORE_HANDLER, $param)) {
            call_user_func($callable, $this->result);
            $route->trigger(Route::EVENT_AFTER_HANDLER, $param);
            return true;
        }
        $this->result->setHandler(null);
        return false;
    }
36330
public static function options($path, $callback)
    {
        self::instance()->addRoute('OPTIONS', $path, self::callback($callback));
    }
675103
public function when($name, callable $callback, callable $default = null, array $context = [])
    {
        if ($this->isActive($name, $context)) {
            return $callback($this->params($name), $context);
        } elseif ($default) {
            return $default($this->params($name), $context);
        }

        return $this;
    }