class PjaxResponseNegotiator

Handle the X-Pjax header that AJAX responses may provide, returning the fragment, or, in the case of non-AJAX form submissions, redirecting back to the submitter.

X-Pjax ensures that users won't end up seeing the unstyled form HTML in their browser.

If a JS error prevents the Ajax overriding of form submissions from happening.

It also provides better non-JS operation.

Caution: This API is volatile, and might eventually be replaced by a generic action helper system for controllers.

Methods

__construct($callbacks = array(), $response = null)

No description

getResponse()

No description

setResponse($response)

No description

respond(SS_HTTPRequest $request, $extraCallbacks = array())

Out of the box, the handler "CurrentForm" value, which will return the rendered form.

setCallback(String $fragment, Callable $callback)

No description

setFragmentOverride(array $fragments)

Set up fragment overriding - will completely replace the incoming fragments.

array
getFragmentOverride()

No description

Details

at line 42
__construct($callbacks = array(), $response = null)

Parameters

$callbacks
$response

at line 47
getResponse()

at line 52
setResponse($response)

Parameters

$response

at line 67
SS_HTTPResponse respond(SS_HTTPRequest $request, $extraCallbacks = array())

Out of the box, the handler "CurrentForm" value, which will return the rendered form.

Non-Ajax calls will redirect back.

Parameters

SS_HTTPRequest $request
$extraCallbacks

Return Value

SS_HTTPResponse

at line 105
setCallback(String $fragment, Callable $callback)

Parameters

String $fragment
Callable $callback

at line 114
setFragmentOverride(array $fragments)

Set up fragment overriding - will completely replace the incoming fragments.

Parameters

array $fragments Fragments to insert.

at line 125
array getFragmentOverride()

Return Value

array