Detailed Description
SaveController is a controller that saves Node data.
The controller supports the following actions:
Parameter | Description |
---|---|
in / out | Key/value pairs of serialized object ids and PersistentObject instances to save |
in uploadDir | The directory where attached files should be stored on the server (optional) (see SaveController::getUploadDir()) |
out oid | The object id of the last newly created object |
Response Actions | |
ok | In all cases |
Definition at line 55 of file SaveController.php.
Public Member Functions | |
__construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration, EventManager $eventManager) | |
__destruct () | |
afterCommit (TransactionEvent $event) | |
Public Member Functions inherited from Controller | |
__construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration) | |
initialize (Request $request, Response $response) | |
execute ($method=null) | |
getRequest () | |
getResponse () | |
Protected Member Functions | |
getFileUtil () | |
validate () | |
doExecute ($method=null) | |
saveUploadFile (ObjectId $oid, $valueName, array $data) | |
isFileUpload (array $data) | |
checkFile (ObjectId $oid, $valueName, $filename, $mimeType=null) | |
getUploadFilename (ObjectId $oid, $valueName, $filename) | |
shouldOverride (ObjectId $oid, $valueName, $filename) | |
getUploadDir (ObjectId $oid, $valueName) | |
Protected Member Functions inherited from Controller | |
executeSubAction ($action) | |
redirect ($location, $key=null, $data=null) | |
getLogger () | |
getSession () | |
getPersistenceFacade () | |
getPermissionManager () | |
getActionMapper () | |
getLocalization () | |
getMessage () | |
getConfiguration () | |
requireTransaction () | |
endTransaction ($commit) | |
isLocalizedRequest () | |
checkLanguageParameter () | |
generateCsrfToken ($name, $refresh=true) | |
validateCsrfToken ($name, $invalidate=true) | |
getLocalSessionValue ($key, $default=null) | |
setLocalSessionValue ($key, $value) | |
clearLocalSessionValues () | |
Additional Inherited Members | |
Public Attributes inherited from Controller | |
const | CSRF_TOKEN_PARAM = 'csrf_token' |
Constructor & Destructor Documentation
◆ __construct()
__construct | ( | Session | $session, |
PersistenceFacade | $persistenceFacade, | ||
PermissionManager | $permissionManager, | ||
ActionMapper | $actionMapper, | ||
Localization | $localization, | ||
Message | $message, | ||
Configuration | $configuration, | ||
EventManager | $eventManager | ||
) |
Constructor.
- Parameters
-
$session $persistenceFacade $permissionManager $actionMapper $localization $message $configuration $eventManager
Definition at line 76 of file SaveController.php.
◆ __destruct()
__destruct | ( | ) |
Destructor.
Definition at line 94 of file SaveController.php.
Member Function Documentation
◆ getFileUtil()
|
protected |
◆ validate()
|
protected |
- See also
- Controller::validate()
Reimplemented from Controller.
Definition at line 112 of file SaveController.php.
◆ doExecute()
|
protected |
- See also
- Controller::doExecute()
Reimplemented from Controller.
Definition at line 123 of file SaveController.php.
◆ afterCommit()
afterCommit | ( | TransactionEvent | $event | ) |
◆ saveUploadFile()
|
protected |
Save uploaded file.
This method calls checkFile which will prevent upload if returning false.
- Parameters
-
$oid The ObjectId of the object to which the file is associated $valueName The name of the value to which the file is associated $data An associative array with keys 'name', 'type', 'tmp_name' as contained in the php $_FILES array.
- Returns
- The final filename if the upload was successful, null on error
Definition at line 346 of file SaveController.php.
◆ isFileUpload()
|
protected |
Check if the given data defines a file upload.
File uploads are defined in an associative array with keys 'name', 'type', 'tmp_name' as contained in the php $_FILES array.
- Parameters
-
$data Array
- Returns
- Boolean
Definition at line 397 of file SaveController.php.
◆ checkFile()
|
protected |
Check if the file is valid for a given object value.
The implementation returns true.
- Note
- subclasses will override this to implement special application requirements.
- Parameters
-
$oid The ObjectId of the object $valueName The name of the value of the object identified by oid $filename The name of the file to upload (including path) $mimeType The mime type of the file (if null it will not be checked) (default: null)
- Returns
- Boolean whether the file is ok or not.
Definition at line 410 of file SaveController.php.
◆ getUploadFilename()
|
protected |
Get the name for the uploaded file.
The implementation replaces all non alphanumerical characters except for ., -, _ with underscores and turns the name to lower case.
- Note
- subclasses will override this to implement special application requirements.
- Parameters
-
$oid The ObjectId of the object $valueName The name of the value of the object identified by oid $filename The name of the file to upload (including path)
- Returns
- The filename
Definition at line 424 of file SaveController.php.
◆ shouldOverride()
|
protected |
Determine what to do if a file with the same name already exists.
The default implementation returns true.
- Note
- subclasses will override this to implement special application requirements.
- Parameters
-
$oid The ObjectId of the object $valueName The name of the value of the object identified by oid $filename The name of the file to upload (including path)
- Returns
- Boolean whether to override the file or to create a new unique filename
Definition at line 437 of file SaveController.php.
◆ getUploadDir()
|
protected |
Get the name of the directory to upload a file to and make sure that it exists.
The default implementation will first look for a parameter 'uploadDir' and then, if it is not given, for an 'uploadDir'. type key in the configuration file (section 'media') and finally for an 'uploadDir' key at the same place.
- Note
- subclasses will override this to implement special application requirements.
- Parameters
-
$oid The ObjectId of the object which will hold the association to the file $valueName The name of the value which will hold the association to the file
- Returns
- The directory name
Definition at line 451 of file SaveController.php.