## Apache Zeta Components Manual :: Docs For Class ezcUrlCreator

### Url::ezcUrlCreator

### Class ezcUrlCreator

ezcUrlCreator makes it easy to create urls from scratch.

Holds a list of urls mapped to aliases. The aliases are used to refer to the urls stored, so the urls will not be hardcoded all over the application code.

Example of use:

1. // register an URL under the alias 'map'
2. ezcUrlCreator :: registerUrl ('map','/images/geo/%s?xsize=%d&ysize=%d&zoom=%d');
4. // retrieve the stored URL under the alias 'map' formatted with parameters
5. $url=ezcUrlCreator :: getUrl ('map','map_norway.gif',450,450,4);
6. // will be: "/images/geo/map_norway.gif?xsize=450&ysize=450&zoom=4"
8. // retrieve the stored URL under the alias 'map' formatted with other parameters
9. $url=ezcUrlCreator :: getUrl ('map','map_sweden.gif',450,450,4);
10. // will be: "/images/geo/map_sweden.gif?xsize=450&ysize=450&zoom=4"

Source for this file: /Url/src/url_creator.php

Version: | //autogen//

### Method Summary

public static string | `getUrl( $name , $args,... )` Returns the URL registered as $name.
public static string | `prependUrl( $name , $suffix )` Returns the URL registerd as $name prepended to $suffix.
public static void | `registerUrl( $name , $url )` Registers $url as $name in the URLs list.

### Methods

#### getUrl

static string getUrl( string $name , mixed $args,... )

Returns the URL registered as $name.

This function accepts a variable number of arguments like the sprintf() function. If you specify more than 1 arguments when calling this function, the registered URL will be formatted using those arguments similar with the sprintf() function. Example:

1. ezcUrlCreator :: registerUrl ('map','/images/geo/%s?xsize=%d&ysize=%d&zoom=%d');
2. echoezcUrlCreator :: getUrl ('map','map_sweden.gif',450,450,4);

will output: /images/geo/map_sweden.gif?xsize=450&ysize=450&zoom=4

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string | The name associated with the URL
`$args,...` | mixed | Optional values which will be vsprintf-ed in the URL

##### Exceptions:

Type | Description
--- | ---
`ezcUrlNotRegisteredException` | if $name is not registered

#### prependUrl

static string prependUrl( string $name , string $suffix )

Returns the URL registerd as $name prepended to $suffix.

Example:

1. ezcUrlCreator :: registerUrl ('map','/images/geo?xsize=450&ysize=450&zoom=4');
2. echoezcUrlCreator :: prependUrl ('map','map_sweden.gif');

will output: /images/geo/map_sweden.gif?xsize=450&ysize=450&zoom=4

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string | The name associated with the URL that will be appended with $suffix
`$suffix` | string | The string which will be appended to the URL

##### Exceptions:

Type | Description
--- | ---
`ezcUrlNotRegisteredException` | if $name is not registered

#### registerUrl

static void registerUrl( string $name , string $url )

Registers $url as $name in the URLs list.

If $name is already registered, it will be overwritten.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string | The name associated with the URL
`$url` | string | The URL to register

Documentation generated by phpDocumentor 1.4.3