Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JApplicationWebRouterBase
+ Graphe d'héritage de JApplicationWebRouterBase:
+ Graphe de collaboration de JApplicationWebRouterBase:

Liste de tous les membres

Fonctions membres publiques

 addMap ($pattern, $controller)
 addMaps ($maps)
- Fonctions membres publiques inherited from JApplicationWebRouter
 __construct (JApplicationWeb $app, JInput $input=null)
 execute ($route)
 setControllerPrefix ($prefix)
 setDefaultController ($name)

Fonctions membres protégées

 parseRoute ($route)
- Fonctions membres protégées inherited from JApplicationWebRouter
 fetchController ($name)

Attributs protégés

 $maps = array()
- Attributs protégés inherited from JApplicationWebRouter
 $app
 $default
 $controllerPrefix
 $input

Description détaillée

Définition à la ligne 19 du fichier base.php.


Documentation des fonctions membres

JApplicationWebRouterBase::addMap (   $pattern,
  $controller 
)

Add a route map to the router. If the pattern already exists it will be overwritten.

Paramètres:
string$patternThe route pattern to use for matching.
string$controllerThe controller name to map to the given pattern.
Renvoie:
JApplicationWebRouter This object for method chaining.
Depuis:
12.2

Définition à la ligne 38 du fichier base.php.

{
// Sanitize and explode the pattern.
$pattern = explode('/', trim(parse_url((string) $pattern, PHP_URL_PATH), ' /'));
// Prepare the route variables
$vars = array();
// Initialize regular expression
$regex = array();
// Loop on each segment
foreach ($pattern as $segment)
{
// Match a splat with no variable.
if ($segment == '*')
{
$regex[] = '.*';
}
// Match a splat and capture the data to a named variable.
elseif ($segment[0] == '*')
{
$vars[] = substr($segment, 1);
$regex[] = '(.*)';
}
// Match an escaped splat segment.
elseif ($segment[0] == '\\' && $segment[1] == '*')
{
$regex[] = '\*' . preg_quote(substr($segment, 2));
}
// Match an unnamed variable without capture.
elseif ($segment == ':')
{
$regex[] = '[^/]*';
}
// Match a named variable and capture the data.
elseif ($segment[0] == ':')
{
$vars[] = substr($segment, 1);
$regex[] = '([^/]*)';
}
// Match a segment with an escaped variable character prefix.
elseif ($segment[0] == '\\' && $segment[1] == ':')
{
$regex[] = preg_quote(substr($segment, 1));
}
// Match the standard segment.
else
{
$regex[] = preg_quote($segment);
}
}
$this->maps[] = array(
'regex' => chr(1) . '^' . implode('/', $regex) . '$' . chr(1),
'vars' => $vars,
'controller' => (string) $controller
);
return $this;
}
JApplicationWebRouterBase::addMaps (   $maps)

Add a route map to the router. If the pattern already exists it will be overwritten.

Paramètres:
array$mapsA list of route maps to add to the router as $pattern => $controller.
Renvoie:
JApplicationWebRouter This object for method chaining.
Depuis:
12.2

Définition à la ligne 109 du fichier base.php.

{
foreach ($maps as $pattern => $controller)
{
$this->addMap($pattern, $controller);
}
return $this;
}
JApplicationWebRouterBase::parseRoute (   $route)
protected

Parse the given route and return the name of a controller mapped to the given route.

Paramètres:
string$routeThe route string for which to find and execute a controller.
Renvoie:
string The controller name for the given route excluding prefix.
Depuis:
12.2
Exceptions:
InvalidArgumentException

Réimplémentée à partir de JApplicationWebRouter.

Définition à la ligne 129 du fichier base.php.

{
$controller = false;
// Trim the query string off.
$route = preg_replace('/([^?]*).*/u', '\1', $route);
// Sanitize and explode the route.
$route = trim(parse_url($route, PHP_URL_PATH), ' /');
// If the route is empty then simply return the default route. No parsing necessary.
if ($route == '')
{
}
// Iterate through all of the known route maps looking for a match.
foreach ($this->maps as $rule)
{
if (preg_match($rule['regex'], $route, $matches))
{
// If we have gotten this far then we have a positive match.
$controller = $rule['controller'];
// Time to set the input variables.
// We are only going to set them if they don't already exist to avoid overwriting things.
foreach ($rule['vars'] as $i => $var)
{
$this->input->def($var, $matches[$i + 1]);
// Don't forget to do an explicit set on the GET superglobal.
$this->input->get->def($var, $matches[$i + 1]);
}
$this->input->def('_rawRoute', $route);
break;
}
}
// We were unable to find a route match for the request. Panic.
if (!$controller)
{
throw new InvalidArgumentException(sprintf('Unable to handle request for route `%s`.', $route), 404);
}
return $controller;
}

Documentation des données membres

JApplicationWebRouterBase::$maps = array()
protected

Définition à la ligne 26 du fichier base.php.


La documentation de cette classe a été générée à partir du fichier suivant :