Q_Response Class
This class deals with returning a response
Item Index
Methods
- addError static
- addHtmlCssClass static
- addScript static
- addScriptLine static
- addStylesheet static
- addTemplate static
- clearCookie static
- clearSlot static
- faviconUrl static
- fillSlot static
- getAllSlots static
- getErrors static
- getNotices static
- getRemovedNotices static
- getRequestedSlots static
- getSlot static
- getToolOptions static
- htmlAttributes static
- isBuffered static
- language static
- layoutView static
- metas static
- metasArray static
- metasInline static
- output static
- redirect static
- removeNotice static
- retainSlot static
- scriptData static
- scriptData static
- scriptLines static
- scriptLinesArray static
- scripts static
- scriptsArray static
- scriptsInline static
- sendCookieHeaders static
- setCookie static
- setIgnoreUserAbort static
- setMeta static
- setNotice static
- setScriptData
- setSlot static
- setStyle static
- setToolOptions static
- shouldReplaceWithTool static
- shouldRetainTool static
- slots static
- styles static
- stylesArray static
- stylesheets static
- stylesheetsArray static
- stylesheetsInline static
- stylesInline static
- supportCORS
- templates static
- templatesArray static
- toolReplace static
- toolRetain static
Properties
- $batch static
- $cookies static
- $errors static
- $faviconUrl static
- $htmlCssClasses static
- $inlineTemplates static
- $isBuffered static
- $language static
- $layout_view static
- $metas static
- $metasForSlot static
- $notices static
- $redirected static
- $removedNotices static
- $retainSlot static
- $scriptDataForSlot static
- $scriptLines static
- $scriptLinesForSlot static
- $scripts static
- $scriptsForSlot static
- $slotName static
- $slots static
- $styles static
- $stylesForSlot static
- $stylesheets static
- $stylesheetsForSlot static
- $templates static
- $toolOptions static
- $toolRetain static
- $toolRetain static
Methods
addError
-
$exception
Adds an error to the response
Parameters:
-
$exception
Q_Exception | ArrayEither a Q_Exception or an array of them
addHtmlCssClass
-
$className
Call this method to add a css class to the HTML element in the layout
Parameters:
-
$className
String
addScript
-
$src
-
[$slotName=null]
-
[$type='text/javascript']
Adds a script reference to the response
Parameters:
-
$src
String -
[$slotName=null]
String optional -
[$type='text/javascript']
String optional
Returns:
returns false if script was already added, else returns true
addScriptLine
-
$line
-
[$replace=array()]
-
[$slotName=null]
Adds a line of script to be echoed in a layout
Parameters:
-
$line
StringThe line of script
-
[$replace=array()]
Array optionalKeys in this array are globally replaced in the $line with the json_encoded values, before the line is added.
-
[$slotName=null]
Array optionalA way to override the slot name. Pass "" here to have the script lines be returned first by Q_Response::scriptLines. The other special value, "Q", is intended for internal use.
addStylesheet
-
$href
-
[$slotName=null]
-
[$media='screen,print']
-
[$type='text/css']
Adds a stylesheet
Parameters:
-
$href
String -
[$slotName=null]
String optional -
[$media='screen,print']
String optional -
[$type='text/css']
String optional
Returns:
returns false if a stylesheet with exactly the same parameters has already been added, else true.
addTemplate
-
$name
-
[$slotName=null]
-
[$type="handlebars"]
-
[$params=array()]
Adds inline template to the response
Parameters:
-
$name
StringThe location of the template file relative to the "views" folder
-
[$slotName=null]
Array optionalA way to override the slot name. Pass "" here to have the script lines be returned first by Q_Response::scriptLines. The other special value, "Q", is intended for internal use.
-
[$type="handlebars"]
String optionalThe type of the template, such as "php" or "handlebars".
-
[$params=array()]
Array optionalOptional array of parameters to pass to PHP
Returns:
returns false if template was already added, else returns true
clearCookie
-
$name
-
[$path=false]
Parameters:
-
$name
String -
[$path=false]
String optional
Returns:
clearSlot
-
$slotName
Clears a slot, so the next call to Q_Response::fillSlot would fill it again
Parameters:
-
$slotName
StringThe name of the slot.
faviconUrl
-
[$new_url=null]
Gets/sets the favicon url
Parameters:
-
[$new_url=null]
String optional
Returns:
fillSlot
-
$slotName
-
[$default_slotName=null]
-
[$prefix=null]
Gets the current content of a slot, if any. If slot content is null, then raises an event to try to fill the slot. If it is filled, returns the content. Otherwise, returns null.
Parameters:
-
$slotName
String | ArrayThe name of the slot.
-
[$default_slotName=null]
Boolean optionalIf the slot named in $slotName returns null, the handler corresponding to the default slot will be called, passing it the requested slot's name in the 'slotName' parameter, and its value will be returned instead. Note: this does not fill the slot named $default_slotName! That is to say, the computed value is not saved, so that the slot's handler is called again if it is ever consulted again.
-
[$prefix=null]
String optionalSets a prefix for the HTML ids of all the elements in the slot.
Returns:
getAllSlots
()
Array
static
Gets all the slots that have been set
Returns:
getErrors
()
Array
static
Returns all the errors added so far to the response.
Returns:
getNotices
()
Array
static
Returns all the notices added so far to the response.
Returns:
getRemovedNotices
()
Array
static
Returns all the notices removed so far during this request
Returns:
getRequestedSlots
()
Array
static
Gets all the requested slots using Q_Request::slotNames()
Returns:
getSlot
-
$slotName
Gets the content of a slot, or null if it wasn't filled
Parameters:
-
$slotName
StringThe name of the slot.
Returns:
getToolOptions
-
toolName
Get all the options set for a tool so far
Parameters:
-
toolName
StringOptional name of the tool that is being rendered
Returns:
The options for the tool currently being rendered
htmlAttributes
()
String
static
Returns the string containing all the html attributes
Returns:
isBuffered
-
[$new_value=null]
Gets or sets whether the response is buffered.
Parameters:
-
[$new_value=null]
Boolean | String optionalIf not present, just returns the current value of this setting. If true or false, sets the setting to this value, and returns the setting's old value.
Returns:
language
-
[$newLanguage]
Used to get or set the language (two-letter lowercase ISO code) of the output page. Defaults to "en". It is used in htmlAttributes method.
Parameters:
-
[$newLanguage]
String optionalSet a new code here to change the language
Returns:
layoutView
-
$newView
Get or set the layout view that should be used in the response
Parameters:
-
$newView
Stringoptionally set the new view, or unset it by passing false
Returns:
metas
-
[$slotName=null]
-
[$between='']
-
[$alsoAsProperty='og']
Returns text describing all the metas inline which have been added with setMeta()
Parameters:
-
[$slotName=null]
String optionalIf provided, returns only the metas set while filling this slot.
-
[$between='']
String optionalOptional text to insert between the <meta> tags or blocks of text.
-
[$alsoAsProperty='og']
String optionalAlso output this meta tag as a meta "property", see ogp.me
Returns:
metasArray
-
[$slotName=null]
-
[$urls=true]
Return the array of metas added so far
Parameters:
-
[$slotName=null]
String optionalIf provided, returns only the metas set while filling this slot. If you leave this empty, you get metas information for the "right" slots. If you pass false here, you will just get the entire $metas array without any processing.
-
[$urls=true]
String optionalIf true, transforms all the 'src' values into URLs before returning.
Returns:
if $slotName is an array or true, returns array of $slotName => $metas, otherwise returns $metas
metasInline
-
[$slotName=null]
-
[$between='']
Returns text describing all the metas inline which have been added with setMeta(), to be included between <meta></meta> tags.
Parameters:
-
[$slotName=null]
String optionalIf provided, returns only the metas set while filling this slot.
-
[$between='']
String optionalOptional text to insert between the blocks of meta text
Returns:
output
-
[$new_output=null]
-
[$override=false]
Used to get/set output that the Q/response handler should consult.
Parameters:
-
[$new_output=null]
String optionalPass a string here to return as output, instead of the usual layout. Or, pass true here to indicate that we have already returned the output, and to skip rendering a layout.
-
[$override=false]
Boolean optionalIf an output string is already set, calling this method wouldn't override it unless you pass true here.
Returns:
Returns the output that was set, if any
redirect
-
$uri
-
$options
-
[$noProxy=false]
Sets a header to redirect to a given URI or URL.
Parameters:
-
$uri
StringThe URL or internal URI to redirect to
-
$options
ArrayAn array of options that can include:
-
[loop=false]
Boolean optionalIf false, and current URL is the same as the new one, skips setting the redirect header and just returns false.
-
[permanently=false]
Boolean optionalIf true, sets response code as 304 instead of 302
-
[noProxy=false]
Boolean optionalIf true, doesn't use the proxy mapping to determine URL
-
-
[$noProxy=false]
Boolean optional
Returns:
Return whether the redirect header was set.
removeNotice
-
$key
Removes a notice
Parameters:
-
$key
String
Returns:
true if notice has been deleted, false otherwise
retainSlot
-
[$toRetain=true]
Parameters:
-
[$toRetain=true]
Boolean optionalDefaults to true. Whether to cache the slot being rendered.
scriptData
-
[$slotName=null]
Returns json describing all the script data that has been added to various slots
Parameters:
-
[$slotName=null]
String optionalBy default, returns all the lines in their intended order. Pass a slot name here to return only the script lines added while filling this slot. Pass false here to return the script lines in the order they were added.
Returns:
scriptData
-
[$slotName=null]
Returns json describing all the templates that has been added to various slots
Parameters:
-
[$slotName=null]
String optionalBy default, returns all the lines in their intended order. Pass a slot name here to return only the templates added while filling this slot. Pass false here to return the templates in the order they were added.
Returns:
scriptLines
-
[$slotName=null]
-
[$without_script_data=false]
-
[$between='']
-
[$tags=true]
Returns text describing all the scripts lines that have been added, to be included between <script></script> tags.
Parameters:
-
[$slotName=null]
String optionalBy default, returns all the lines in their intended order. Pass a slot name here to return only the script lines added while filling this slot. Pass false here to return the script lines in the order they were added.
-
[$without_script_data=false]
Boolean optionalBy default, a few script lines are prepended to insert the script data, for backward compatibility with apps that were built before scriptData was introduced. Pass true here if you don't want to include them in the result.
-
[$between='']
String optionalOptional text to insert between the <style> tags or blocks of text.
-
[$tags=true]
Boolean optionalWhether to return the text already wrapped in