ICanBoogie
  • Documentation
  • API Reference
  • Operation 2.2.x
Namespaces
  • ICanBoogie
    • Operation
      • OperationDispatcher
Classes
  • BeforeControlEvent
  • BeforeProcessEvent
  • BeforeValidateEvent
  • ControlEvent
  • FailureEvent
  • GetFormEvent
  • Hooks
  • OperationDispatcher
  • PingOperation
  • ProcessEvent
  • RescueEvent
  • Response
  • ValidateEvent
Interfaces
  • Exception
Traits
  • ControlEventTrait
  • ValidateEventTrait
Exceptions
  • Failure
  • FormHasExpired
  • FormNotFound

Class OperationDispatcher

Dispatches operation requests.

ICanBoogie\Operation\OperationDispatcher implements ICanBoogie\HTTP\Dispatcher
Namespace: ICanBoogie\Operation
Located at OperationDispatcher.php

Methods summary

public __invoke( ICanBoogie\HTTP\Request $request )

Tries to create an ICanBoogie\Operation instance from the specified request. The operation is then executed and its response returned.

Tries to create an ICanBoogie\Operation instance from the specified request. The operation is then executed and its response returned.

If an operation could be created from the request, the operation property of the request's context is set to that operation.

For forwarded operation, successful responses are not returned unless the request is an XHR or the response has a location.

Inheritdoc

protected respond( ICanBoogie\Operation $operation, ICanBoogie\HTTP\Request $request ) : ICanBoogie\Operation\Response|null

Executes the operation and returns a response.

Executes the operation and returns a response.

Parameters

$operation
$request

Returns

ICanBoogie\Operation\Response|null
public rescue( ICanBoogie\Operation\Exception $exception, ICanBoogie\HTTP\Request $request ) : ICanBoogie\Operation\Response|null

Try to rescue the exception.

Try to rescue the exception.

The rescue process consists in the following steps:

  1. The operation associated with the exception cannot be retrieved the exception is re-thrown.
  2. Otherwise, the ICanBoogie\Operation::rescue event of class ICanBoogie\Operation\RescueEvent is fired. Event hooks attached to this event may replace the exception or provide a response. If a response is provided it is returned.
  3. Otherwise, if the exception is not an instance of ICanBoogie\Operation\Failure the exception is re-thrown.
  4. Otherwise, if the request is an XHR the response of the operation is returned.
  5. Otherwise, if the operation was forwarded the exception message is logged as an error and the method returns.
  6. Otherwise, the exception is re-thrown.

In summary, a failed operation is rescued if a response is provided during the ICanBoogie\Operation::rescue event, or later if the request is an XHR. Although the rescue of an operation might be successful, the returned response can be an error response.

Parameters

$exception
The exception to rescue.
$request
The request.

Returns

ICanBoogie\Operation\Response|null
A response or null if the operation was forwarded.

Throws

ICanBoogie\Operation\Failure
Exception
protected retrieve_operation( ICanBoogie\Operation\Exception & $exception, ICanBoogie\HTTP\Request $request, ICanBoogie\Operation\Failure & $failure = null ) : ICanBoogie\Operation

Retrieve the operation from the exception or request.

Retrieve the operation from the exception or request.

Parameters

$exception
$request
$failure

Returns

ICanBoogie\Operation

Throws

Exception
when the operation cannot be retrieved, that is the original exception.
Operation 2.2.x – Check on GitHub – API documentation generated by ApiGen