Net_URL_Mapper
[ class tree: Net_URL_Mapper ] [ index: Net_URL_Mapper ] [ all elements ]

Class: Net_URL_Mapper

Source Location: /Net_URL_Mapper-0.9.1/Mapper.php

Class Overview


URL parser and mapper class


Author(s):

Version:

  • Release: @package_version@

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 58]
URL parser and mapper class

This class takes an URL and a configuration and returns formatted data about the request according to a configuration parameter



[ Top ]


Class Variables

$id =  '__default__'

[line 88]

Mapper instance id
  • Access: protected

Type:   string


[ Top ]

$paths = array()

[line 70]

Mapped paths collection
  • Access: protected

Type:   array


[ Top ]

$prefix =  ''

[line 76]

Prefix used for url mapping
  • Access: protected

Type:   string


[ Top ]

$scriptname =  ''

[line 82]

Optional scriptname if mod_rewrite is not available
  • Access: protected

Type:   string


[ Top ]



Method Detail

addPath   [line 318]

void addPath( Net_URL_Mapper_Path $path)

Add a new path to the mapper
  • Access: public

Parameters:

object Net_URL_Mapper_Path   $path   —  object

[ Top ]

connect   [line 127]

object Net_URL_Mapper_Path connect( string $path, [array $defaults = array()], [array $rules = array()])

Parses a path and creates a connection
  • Access: public

Parameters:

string   $path   —  The path to connect
array   $defaults   —  Default values for path parts
array   $rules   —  Regular expressions for path parts

[ Top ]

generate   [line 265]

string|false generate( [array $values = array()], [array $qstring = array()], [string $anchor = ''])

Generate an url based on given parameters

Will attempt to find a path definition that matches the given parameters and will generate an url based on this path.

  • Return: String if a rule was found, false otherwise
  • Access: public

Parameters:

array   $values   —  Values to be used for the url generation
array   $qstring   —  Key/value pairs for query string if needed
string   $anchor   —  Anchor (fragment) if needed

[ Top ]

getId   [line 115]

string getId( )

Returns the instance id
  • Return: Mapper instance id
  • Access: public

[ Top ]

getInstance   [line 101]

Object getInstance( [string $id = '__default__'])

Returns a singleton object corresponding to the requested instance id
  • Return: Net_URL_Mapper Singleton
  • Access: public

Parameters:

string   $id   —  Requested instance name

[ Top ]

getPaths   [line 299]

array getPaths( )

Returns defined paths
  • Return: Array of paths
  • Access: public

[ Top ]

match   [line 180]

array|null match( string $url)

Will attempt to match an url with a defined path

If an url corresponds to a path, the resulting values are returned in an array. If none is found, null is returned. In case an url is matched but its content doesn't validate the path rules, an exception is thrown.

  • Return: array if match found, null otherwise
  • Throws: Net_URL_Mapper_InvalidException
  • Access: public

Parameters:

string   $url   —  URL

[ Top ]

reset   [line 308]

void reset( )

Reset all paths

This is probably only useful for testing

  • Access: public

[ Top ]

setPrefix   [line 147]

void setPrefix( string $prefix)

Set the url prefix if needed

Example: using the prefix to differenciate mapper instances

  1.  $fr Net_URL_Mapper::getInstance('fr');
  2.  $fr->setPrefix('/fr');
  3.  $en Net_URL_Mapper::getInstance('en');
  4.  $en->setPrefix('/en');

  • Access: public

Parameters:

string   $prefix   —  URL prefix

[ Top ]

setScriptname   [line 163]

void setScriptname( string $scriptname)

Set the scriptname if mod_rewrite not available

Example: will match and generate url like

  • Access: public

Parameters:

string   $scriptname   —  URL prefix

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:41:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.