isoTope Documentation: Request object
The Request object is the heart of the AtomAPI implementation, it is the encapsulation of an Atom HTTP request. It does not replace the standard PHP variables, but as a supplement.
Each atom request created an instance of this object named $req
. This object is global so to use it add global $req;
to each method that needs to reference this object.
The Request
object offers the following variables and methods:
Variables
$req->dom
This contains a reference to the DOM-representation of the received XML document. It is populated when the HTTP method is POST
or PUT
.
$req->query
A copy of the PHP variable $_GET
. Useful on GET
and DELETE
HTTP methods.
$req->urlPrefix
This contains the domain name of the current implementation. Used for creating URLs.
$req->rootUri
This returns the prefix of the request that maps to the root of the Atom implementation.
$req->method
This returns the HTTP method of the current request.
$req->contentType
This returns the specified HTTP Content-Type of the request, which specifies the content-type of the HTTP Request entity body. This would be application/x.atom+xml
for AtomAPI requests. Typically this would be used on POST
and PUT
requests.
$req->extension
This returns the file extension found on the URL. This is useful in allowing user-agents to override the default response content-type. For example, suffixing any URL with .html
can allow a text/html
response.
One situation where this is useful is to show, for debugging, an entry in its Atom format in a browser that doesn't support application/x.atom+xml
.
$req->responseType
This returns the derived response mime-type of the request. This is done by examining the HTTP Accept
header, and allowing the URL extensions to override it.
$req->service
Returns the atom service as specified by the URL. This string is used as the service key which instantiates both the ServiceHandler and the StoreHandler. By default, the service is the first directory / folder specified after the $req->rootUri
.
Array $req->breadcrumb
This returns an array of folders / files created from the request URL. This is typically used by the ServiceHandler
initialisation to extract entry or comment identifiers.
$req->pageUri
This returns the URI of the requested service, so without any entry or comment identifiers. This is used to create links to the service or resources within a service.
Methods
Request()
The Request object constructor which initialises the request object based on the received HTTP request.
$req->addMsg($msg)
This function is used to log debug or informational messages. This information is typically appended to a log file, or it can be echoed out as part of the response.