Skip to content

Commit

Permalink
- Explained better the relation between ordered and unordered paramet…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
as:ez.no committed Dec 11, 2008
1 parent f9a5432 commit 9c896b9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/tutorial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ Where::
ordered parameters = "groups", "Games", "Adventure", "Adult"
unordered parameters = array( "Larry", "7" )

When creating a configuration with ordered parameters, those parameters are
required to be present in the parsed URL, in the same number as the
configuration states. Having a different number of ordered parameters in the
parsed URL will lead to wrong values assigned to the unordered parameters (if
any follow the ordered parameters).

Working with a variable number of ordered parameters is explained in the
`Changing a url configuration dynamically`_ section.

Working with the query part
===========================

Expand Down
12 changes: 12 additions & 0 deletions src/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
* ordered parameters = "groups", "Games", "Adventure", "Adult"
* unordered parameters = array( "Larry", "7" )
*
* When creating a configuration with ordered parameters, those parameters are
* required to be present in the parsed URL, in the same number as the
* configuration states. Having a different number of ordered parameters in the
* parsed URL will lead to wrong values assigned to the unordered parameters (if
* any follow the ordered parameters).
*
* See the tutorial for a way to change configurations dynamically based on
* the ordered parameters.
*
* Example of use:
* <code>
* // create an ezcUrlConfiguration object
Expand Down Expand Up @@ -574,6 +583,9 @@ public function isRelative()
* Returns the value of the specified parameter from the URL based on the
* active URL configuration.
*
* Ordered parameters must appear before unordered parameters in the parsed
* URL, in the same number and order as they are defined in the configuration.
*
* Unordered parameter examples:
* <code>
* $urlCfg = new ezcUrlConfiguration();
Expand Down
31 changes: 31 additions & 0 deletions src/url_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@
/**
* ezcUrlConfiguration makes it possible to use a custom URL form in your application.
*
* A URL is assumed to be of this form:
* scheme://host/basedir/script/ordered_parameters/unordered_parameters
*
* Example:
* http://example.com/mydir/index.php/groups/Games/Adventure/Adult/(game)/Larry/7
*
* Where:
* scheme = "http"
* host = "example.com"
* basedir = "mydir"
* script = "index.php"
* ordered parameters = "groups", "Games", "Adventure", "Adult"
* unordered parameters = array( "Larry", "7" )
*
* When creating a configuration with ordered parameters, those parameters are
* required to be present in the parsed URL, in the same number as the
* configuration states. Having a different number of ordered parameters in the
* parsed URL will lead to wrong values assigned to the unordered parameters (if
* any follow the ordered parameters).
*
* See the tutorial for a way to change configurations dynamically based on
* the ordered parameters.
*
* Example of use:
* <code>
* // create an ezcUrlConfiguration object
Expand Down Expand Up @@ -236,6 +259,10 @@ public function __isset( $name )
/**
* Adds an ordered parameter to the URL configuration.
*
* Ordered parameters must be added before unordered parameters, and
* they must appear in the parsed URL in the same number and order
* as they are defined in the configuration.
*
* @param string $name The name of the ordered parameter to add to the configuration
*/
public function addOrderedParameter( $name )
Expand Down Expand Up @@ -289,6 +316,10 @@ public function removeOrderedParameter( $name )
* $param1 = $url->getParam( 'param1' ); // will return array( array( "x" ), array( "y", "z" ) )
* </code>
*
* Ordered parameters must be added before unordered parameters, and
* they must appear in the parsed URL in the same number and order
* as they are defined in the configuration.
*
* @param string $name The name of the unordered parameter to add to the configuration
* @param int $type The type of the unordered parameter
*/
Expand Down

0 comments on commit 9c896b9

Please sign in to comment.