Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • ConfigBlock
  • ConfigOperation
  • DeleteOperation
  • DownloadOperation
  • EditBlock
  • File
  • FileUpload
  • GetOperation
  • ManageBlock
  • Model
  • Module
  • SaveOperation
  • UploadOperation

Class UploadOperation

Upload a file to the repository's temporary folder.

ICanBoogie\Object implements ICanBoogie\ToArrayRecursive uses ICanBoogie\ToArrayRecursiveTrait, ICanBoogie\PrototypeTrait
Extended by ICanBoogie\Operation
Extended by Icybee\Modules\Files\UploadOperation

Direct known subclasses

Icybee\Modules\Images\UploadOperation

Namespace: Icybee\Modules\Files
Located at vendor/icanboogie-modules/files/lib/operations/upload.php

Methods summary

protected
# get_file( )
protected array
# get_controls( )

Controls for the operation: permission(create).

Controls for the operation: permission(create).

Returns

array
All the controls set to false.

Overrides

ICanBoogie\Operation::get_controls
public 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 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\Files\UploadOperation::process() method, it is controlled and validated using the ICanBoogie\Operation::control() and Icybee\Modules\Files\UploadOperation::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\Files\UploadOperation::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\Files\UploadOperation::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

Operation\Response
The response of the operation.

Throws

Failure
when the response has a client or server error, or the FormHasExpired exception was raised.

Overrides

ICanBoogie\Operation::__invoke
protected boolean
# validate( ICanboogie\Errors $errors )

Validates the operation if the file upload succeeded.

Validates the operation if the file upload succeeded.

Returns

boolean
true if the operation is valid, false otherwise.

Throws

Exception
If something horribly wrong happens.
protected mixed
# process( )

Processes the operation.

Processes the operation.

The method is abstract and therefore must be implemented by subclasses.

Returns

mixed
Depends on the implementation.

Methods inherited from ICanBoogie\Operation

__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()

Methods inherited from ICanBoogie\Object

resolve_facade_properties(), resolve_private_properties(), to_array(), to_json()

Methods inherited from ICanBoogie\ToArrayRecursive

to_array_recursive()

Methods used from ICanBoogie\ToArrayRecursiveTrait

to_array_recursive()

Methods used from ICanBoogie\PrototypeTrait

__call(), __get(), __set(), __sleep(), __wakeup(), get_prototype(), has_method(), has_property(), last_chance_get(), last_chance_set()

Magic methods summary

Constants summary

Constants inherited from ICanBoogie\Operation

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

protected ICanBoogie\HTTP\File $file
#

The target file of the operation.

The target file of the operation.

protected array $accept
#

Accepted file types.

Accepted file types.

Properties inherited from ICanBoogie\Operation

$destination, $form, $format, $key, $method, $module, $properties, $request, $response

Magic properties

public read-only ICanBoogie\HTTP\File $file
#

The uploaded file.

The uploaded file.

Magic properties inherited from ICanBoogie\Operation

$is_forwarded, $record, $request

Magic properties inherited from ICanBoogie\Object

$prototype

Autodoc API documentation generated by ApiGen 2.8.0