File code/addon/Router.php

class Lia\Addon\Router

Constants

Properties

  • $dlm = $thisvarDelim;
  • $params = [];
  • $optionalParams = [];
  • $optionalParams[] $matches[2];

Methods

  • public function __construct($lia=null, $namenull) Callables that can route a request & return false if they don't route

  • public function dir_to_patterns($dir, $prefix='') Get an array of patterns from files in a directory.

  • public function fileToPattern($relFile) Convert a relative file path into a pattern

  • public function clean_url($dirty_url) Clean a url (without domain): replace space with '+', single quote with '%27', and replace multiple slashes with a single slash

  • public function handle_route_prefix_method($object, $m, $dot_name) Get routes by calling the object's method & use the method as the router.

  • public function addRoute($pattern, $callbackOrFile,$package=null) Add a route

  • public function separate_optional_from_decoded_pattern($original_parsed) Facilitates optional paramaters

Processes a parsed pattern into an array of valid parsed patterns where the original pattern may contain details for optional paramaters

  • public function addRouter(callable $router) add a callable as a router. It will be called with a \Lia\Obj\Request object as the only paramater
  • public function route(\Lia\Obj\Request $request) get a route for the given request