Class NavigationIncludeOperation
-
ICanBoogie\Object
implements
ICanBoogie\ToArrayRecursive
uses
ICanBoogie\ToArrayRecursiveTrait,
ICanBoogie\PrototypeTrait
-
ICanBoogie\Operation
-
Icybee\Modules\Pages\NavigationIncludeOperation
Methods summary
protected
array
|
#
get_controls( )
Returns the controls to pass.
Returns the controls to pass.
Returns
array All the controls set to false.
Overrides
|
public
ICanBoogie\Operation\Response
|
#
__invoke( ICanBoogie\HTTP\Request $request )
Handles the operation and prints or returns its result.
Handles the operation and prints or returns its result.
The $record, ICanBoogie\Operation::$form and ICanBoogie\Operation::$properties properties are
unset in order for their getters to be called on the next access, while keeping
their scope.
The response object
The operation result is saved in a _response_ object, which may contain meta
data describing or accompanying the result. For example, the ICanBoogie\Operation
class returns success and error messages in the $message and $errors properties.
Depending on the Accept header of the request, the response
object can be formatted as JSON or XML. If the Accept header is
"application/json" the response is formatted as JSON. If the Accept
header is "application/xml" the response is formatted as XML. If the
Accept header is not of a supported type, only the result is
printed, as a string.
For API requests, the output format can also be defined by appending the
corresponding extension to the request path:
/api/system.nodes/12/online.json
The response location
The Location header is used to ask the browser to load a
different web page. This is often used to redirect the user when an operation
has been performed e.g. creating/deleting a resource. The location
property of the response is used to set that header. This is not a desirable
behavior for XHR because although we might want to redirect the user, we still
need to get the result of our request first. That is why when the
location property is set, and the request is an XHR, the location
is set to the redirect_to field and the location
property is set to null to disable browser redirection.
Control, validation and processing
Before the operation is actually processed with the Icybee\Modules\Pages\NavigationIncludeOperation::process() method,
it is controlled and validated using the ICanBoogie\Operation::control() and Icybee\Modules\Pages\NavigationIncludeOperation::validate() methods. If the control or validation fail the operation is not
processed.
The controls passed to the ICanBoogie\Operation::control() method are obtained through the
$controls property or the Icybee\Modules\Pages\NavigationIncludeOperation::get_controls() getter if the property
is not accessible.
Events
The failure event is fired when the control or validation of the
operation failed. The type property of the event is "control" or
"validation" depending on which method failed. Note that the event won't be
fired if an exception is thrown.
The process:before event is fired with the operation as sender
before the operation is processed using the Icybee\Modules\Pages\NavigationIncludeOperation::process() method.
The process event is fired with the operation as sender after
the operation has been processed if its result is not null .
Failed operation
If the result of the operation is null , the operation is
considered as failed, in which case the status code of the response is changed
to 404 and the ProcessEvent is not fired.
Note that exceptions are not caught by the method.
Parameters
- $request
HTTP\Request $request The request triggering the operation.
Returns
Throws
Failure when the response has a client or server error, or the FormHasExpired
exception was raised.
Overrides
|
protected
boolean
|
#
validate( ICanboogie\Errors $errors )
Validates the operation before processing.
Validates the operation before processing.
The method is abstract and therefore must be implemented by subclasses.
Returns
boolean true if the operation is valid, false otherwise.
Throws
Exception
If something horribly wrong happens.
|
protected
mixed
|
#
process( )
Processes the operation.
The method is abstract and therefore must be implemented by subclasses.
Returns
mixed Depends on the implementation.
|
__construct()
,
control()
,
control_authentication()
,
control_form()
,
control_method()
,
control_ownership()
,
control_permission()
,
control_record()
,
control_session_token()
,
encode()
,
format_class_name()
,
from()
,
from_module_request()
,
from_request()
,
from_route()
,
get_is_forwarded()
,
get_module()
,
get_request()
,
get_response()
,
lazy_get_form()
,
lazy_get_properties()
,
lazy_get_record()
,
reset()
resolve_facade_properties()
,
resolve_private_properties()
,
to_array()
,
to_json()
to_array_recursive()
to_array_recursive()
__call()
,
__get()
,
__set()
,
__sleep()
,
__wakeup()
,
get_prototype()
,
has_method()
,
has_property()
,
last_chance_get()
,
last_chance_set()
Magic methods summary
Constants summary
CONTROL_AUTHENTICATION
,
CONTROL_FORM
,
CONTROL_METHOD
,
CONTROL_OWNERSHIP
,
CONTROL_PERMISSION
,
CONTROL_RECORD
,
CONTROL_SESSION_TOKEN
,
DESTINATION
,
KEY
,
NAME
,
RESTFUL_BASE
,
RESTFUL_BASE_LENGTH
,
SESSION_TOKEN
Properties summary
$destination
,
$form
,
$format
,
$key
,
$method
,
$module
,
$properties
,
$request
,
$response
$is_forwarded
,
$record
,
$request
$prototype