Download the PHP package moderntribe/square1-request without Composer
On this page you can find all versions of the php package moderntribe/square1-request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package square1-request
Request Object
Tribe Libs provides a Request helper object in order to allow easy access to common request (or server) related values, such as headers, input values, and URL/path information.
Usage
This object can be made available to your classes via direct injection in your constructor
Once injected, the Request object will automatically contain the various values relating to the current request. For instance,
to access the Content-Type
header, you could use:
The Request Object is also available via a Facade for usage in classes in which you don't have control over the Constructor (such as a Controller) in order to inject the class as you normally would.
Methods
query()
Get the current \WP_Query
global object. Note that this always grabs the global $wp_query
at the time of calling in
order to provide the most-up-to-date version of the object, so it can be used just like global $wp_query
can within hooks.
headers()
Get all of the headers for this request.
header( $key )
Get the header value by key.
input( $key )
Get the input from the Request by key. Automatically detects the method (GET, POST, JSON body) and returns the value from the correct method values.
all()
Get all input values from the Request. Automatically detects method and pulls in the values from there. If method is not GET and the request also has query parameters, returns both the method input and the query parameters.
only( $keys )
Return only input values matching the provided keys. Returns an array containing only those keys which existed (including empty values). Will not return values for non-existent keys.
except( $keys )
Return all input values except those matching the provided keys. Returns an empty array if no other values exist beyond the provided keys.
has( $key )
Determine whether an input matching the provided key exists in the Request. Will return true
if input key exists even if it is empty.
filled( $key )
Determine whether an input matching the provided key exists and is non-empty. Will return true
if value is bool or 0, but
false
for any empty string or null value.
path( $include_params = false )
Get the current Request path. If $include_params
is set to true
, also include any Query Params in the path.
url()
Get the current Request URL. Does not contain path or any Query Parameters.
full_url()
Get the full current Request URL. Includes both the path and any Query Parameters.
is( $path )
Determine if the current Request Path matches the given pattern. Wildcards (*) can be used.