spunQ_DefaultUrlManager Class Reference

The default url manager of spunQ. More...

Inheritance diagram for spunQ_DefaultUrlManager:

spunQ_IUrlManager spunQ_WormholeUrlManager

List of all members.

Public Member Functions

 __construct (spunQ_HttpEntryPoint $entryPoint)
 Constructor.
 getEntryPoint ()
 Provides the spunQ_HttpEntryPoint this object is managing.
 getUrlTemplates ()
 Gets all available url templates for the entry point.
 processDefaultValue ($variable, $typeName, $value)
 Provides the correct value for a default declaration.
 createHtmlLink (spunQ_Locale $locale, array $variables)
 Generates an http link pointing to this manager's entry point.
 generateUrlPart ($urlPart, $value)
 Generates a string part of an actual URL for a url part object.
 regexMatchToVariables (spunQ_DefaultUrlManagerUrlTemplate $urlTemplate, array $matches)
 Implementation for the function with same name in spunQ_IUrlTemplate.

Static Public Member Functions

static getDefaultTypeHandler (spunQ_Type $type, spunQ_Map $options=NULL)
 Returns a type handler for a given type.

Protected Member Functions

 analyze ()
 Creates spunQ_DefaultUrlManagerUrlTemplate objects for the entry point.
 analyzeUrlTemplate ($locale, $urlTemplate, &$localeVariables)
 Generates a url template object for a url definition.
 generateTemplatePart ($templateObject, $part, &$greedy)
 Creates a url template part object for a part of a url template.
 generateRegexTemplatePart ($templateObject, $part, &$greedy)
 Creates a url template part for a part containing a variable.
 generateStaticTemplatePart ($templateObject, $part)
 Creates a url template part for a part not containing a variable.
 processPropertyPath ($partObject)
 Populates members of a part object containing a variable.
 createSubpatternName ($part)
 Creates the name of a regex capture group for given string.
 getTypeHandler ($type, $options)
 Gets the type handler for given type.

Protected Attributes

 $entryPoint
 The spunQ_HttpEntryPoint this object is managing.
 $urlTemplates = array()
 Url templates of the entry point.


Detailed Description

The default url manager of spunQ.

Has a handler class for each type to keep the code readable.

Definition at line 7 of file DefaultUrlManager.class.php.


Constructor & Destructor Documentation

spunQ_DefaultUrlManager::__construct ( spunQ_HttpEntryPoint entryPoint  ) 

Constructor.

Parameters:
$entryPoint the entry point to manage.

Definition at line 55 of file DefaultUrlManager.class.php.


Member Function Documentation

spunQ_DefaultUrlManager::analyze (  )  [protected]

Creates spunQ_DefaultUrlManagerUrlTemplate objects for the entry point.

Called by the constructor to process all url definitions of the entry point. Will populate the $urlTemplates array.

Returns:
void

Definition at line 212 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::analyzeUrlTemplate ( locale,
urlTemplate,
&$  localeVariables 
) [protected]

Generates a url template object for a url definition.

Parameters:
$locale The locale part of the url definition (as the en-uk part in .en-uk foo/bar). This is a string that can be empty (as in @url foo/bar.)
$urlTemplate The string representing the template (the foo/bar part in the examples above.)
$localeVariables Out-parameter that will be populated with variable name that are found in the template declaration. Warning: The variable names are inserted as keys into the array for performance reasons - not as values. So if the variable foo was found, this function will return array('foo'=>1).
Returns:
spunQ_DefaultUrlManagerUrlTemplate

Definition at line 244 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::createHtmlLink ( spunQ_Locale locale,
array $  variables 
)

Generates an http link pointing to this manager's entry point.

If the returned value is not an absolute link (an absolute link is one starting with http://, for example), the returned value will already be run through spunQ_UrlManager::addGlobalPrefix().

Parameters:
$locale Locale to create link for. The manager will decide which url template to use according to this value.
$variables Variables available for the link generation. Missing variables are expected to be pulled from the entry points default declarations.
Returns:
string

Implements spunQ_IUrlManager.

Reimplemented in spunQ_WormholeUrlManager.

Definition at line 98 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::createSubpatternName ( part  )  [protected]

Creates the name of a regex capture group for given string.

See also:
http://php.net/manual/en/regexp.reference.subpatterns.php
Parameters:
$part The name of the url template part to create pattern name for.
Returns:
string

Definition at line 348 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::generateRegexTemplatePart ( templateObject,
part,
&$  greedy 
) [protected]

Creates a url template part for a part containing a variable.

A variable is something like {user} for this url manager.

Parameters:
$templateObject The spunQ_DefaultUrlManagerUrlTemplate to create the part for.
$part String part of the template to process. Must contain a variable declaration (just like the example above).
$greedy Whether the generated regular expression should be greedy.
Returns:
spunQ_DefaultUrlManagerUrlTemplatePart

Definition at line 297 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::generateStaticTemplatePart ( templateObject,
part 
) [protected]

Creates a url template part for a part not containing a variable.

Parameters:
$templateObject The spunQ_DefaultUrlManagerUrlTemplate to create the part for.
$part String part of the template to process.
Returns:
spunQ_DefaultUrlManagerUrlTemplatePart

Definition at line 315 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::generateTemplatePart ( templateObject,
part,
&$  greedy 
) [protected]

Creates a url template part object for a part of a url template.

Parameters:
$templateObject The spunQ_DefaultUrlManagerUrlTemplate to create the part for.
$part String part of the template to process.
$greedy Whether any possibly generated regular expressions should be greedy.
Returns:
spunQ_DefaultUrlManagerUrlTemplatePart

Definition at line 276 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::generateUrlPart ( urlPart,
value 
)

Generates a string part of an actual URL for a url part object.

Parameters:
$urlPart The spunQ_DefaultUrlManagerUrlTemplatePart object to create the string for.
$value The value of the variable for this url part to convert.
Returns:
string Part of the url when generating a link to this manager's entry point.

Definition at line 173 of file DefaultUrlManager.class.php.

static spunQ_DefaultUrlManager::getDefaultTypeHandler ( spunQ_Type type,
spunQ_Map options = NULL 
) [static]

Returns a type handler for a given type.

Parameters:
$type Type to get handler for.
$options Options for the type. Currently unused.
Returns:
spunQ_IDefaultUrlManagerTypeHandler

Definition at line 15 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::getEntryPoint (  ) 

Provides the spunQ_HttpEntryPoint this object is managing.

Returns:
spunQ_HttpEntryPoint

Implements spunQ_IUrlManager.

Definition at line 64 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::getTypeHandler ( type,
options 
) [protected]

Gets the type handler for given type.

Dedicated function for sub-classes to override. Just calls getDefaultTypeHandler() in its current implementation.

Parameters:
$type The type to get handler for.
$options Type options that might be relevant.
Returns:
spunQ_IDefaultUrlManagerTypeHandler

Definition at line 360 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::getUrlTemplates (  ) 

Gets all available url templates for the entry point.

Returns:
array<spunQ_IUrlTemplate>

Implements spunQ_IUrlManager.

Definition at line 71 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::processDefaultValue ( variable,
typeName,
value 
)

Provides the correct value for a default declaration.

The default declaration @default user 14 will return the user with id 14 for the default implementation. Parameters to this function would then be:

  • $variable: user
  • $typeName: string spunQ.user.User.
  • $value: 14
Parameters:
$variable Name of the variable to process value for.
$typeName Type of the variable as string (as declared in the entry point).
$value The default declaration that was given in the entry point's doc comment.
Returns:
any Depends on the $typeName of the $variable.

Implements spunQ_IUrlManager.

Definition at line 78 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::processPropertyPath ( partObject  )  [protected]

Populates members of a part object containing a variable.

This function has not been inlined for child classes to override.

See also:
spunQ_WormholeUrlManager::processPropertyPath()
Parameters:
$partObject The spunQ_DefaultUrlManagerUrlTemplatePart object to process.
Returns:
void

Reimplemented in spunQ_WormholeUrlManager.

Definition at line 329 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::regexMatchToVariables ( spunQ_DefaultUrlManagerUrlTemplate urlTemplate,
array $  matches 
)

Implementation for the function with same name in spunQ_IUrlTemplate.

The url template will pass a call to its regexMatchToVariables() function to this one, since this class knows which template part can handle which part of the regex match.

Parameters:
$urlTemplate The url template that matched the url
$matches Matches of the regular expression as passed to the template by the request router.
Returns:
array<any> Variables that have been extracted out of the regex matches.

Definition at line 190 of file DefaultUrlManager.class.php.


Member Data Documentation

spunQ_DefaultUrlManager::$entryPoint [protected]

The spunQ_HttpEntryPoint this object is managing.

Type:
spunQ_HttpEntryPoint

Definition at line 42 of file DefaultUrlManager.class.php.

spunQ_DefaultUrlManager::$urlTemplates = array() [protected]

Url templates of the entry point.

Populated during analyze().

Type:
array<spunQ_IUrlTemplate>

Definition at line 49 of file DefaultUrlManager.class.php.


The documentation for this class was generated from the following file:

Generated on Fri Jul 1 11:12:39 2011 for spunQ3 by  doxygen 1.5.9