Classe: RequestGenerator - X-Ref
\ingroup Net
Request generators are a way to allow the templates to generate links in an abstract manner regarding of the
current settings. Each request generator defines its own format for its URLs, and by using request generators
we can easily change the format of our URLs without the need to alter our templates
(and therefore, without the need to hardcode URLs in our templates)
This is the class that implements the factory pattern to obtain the correct request generator, given
a BlogInfo object and optionally, a request generator type. If not type is given, then
the class will check the value of the <b>request_format_mode</b> configuration parameter.
The four types of request generators supported as of pLog 1.0 are:
- NORMAL_REQUEST_MODE
- SEARCH_ENGINE_FRIENDLY_MODE
- MODREWRITE_MODE
- CUSTOM_REQUEST_MODE
The preferred way to obtain a request generator is:
<pre>
$rg =& RequestGenerator::getRequestGenerator( $blogInfo );
...
$blogLink = $rg->blogLink();
</pre>
In order to force the factory class to generate a specific request generator:
<pre>
$rg =& RequestGenerator::getRequestGenerator( $blogInfo, CUSTOM_REQUEST_MODE );
</pre>
However, in cases when we have a BlogInfo available it is even better to use the BlogInfo::getBlogRequestGenerator()
method:
<pre>
$rg = $blogInfo->getBlogRequestGenerator();
...
$blogLink = $rg->blogLink();
</pre>
In order to check which methods are available to request generators, please see the documentation of the
RequestGenerator proxy class.