Detailed Description

SaveController is a controller that saves Node data.

The controller supports the following actions:

Action default
Save the given Node values.
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
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 55 of file SaveController.php.

+ Inheritance diagram for SaveController:

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

getFileUtil ( )
protected

Get the FileUtil instance.

Returns
FileUtil

Definition at line 102 of file SaveController.php.

◆ validate()

validate ( )
protected
See also
Controller::validate()

Reimplemented from Controller.

Definition at line 112 of file SaveController.php.

◆ doExecute()

doExecute (   $method = null)
protected
See also
Controller::doExecute()

Reimplemented from Controller.

Definition at line 123 of file SaveController.php.

◆ afterCommit()

afterCommit ( TransactionEvent  $event)

Update oids after commit.

Parameters
$event

Definition at line 318 of file SaveController.php.

◆ saveUploadFile()

saveUploadFile ( ObjectId  $oid,
  $valueName,
array  $data 
)
protected

Save uploaded file.

This method calls checkFile which will prevent upload if returning false.

Parameters
$oidThe ObjectId of the object to which the file is associated
$valueNameThe name of the value to which the file is associated
$dataAn 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()

isFileUpload ( array  $data)
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
$dataArray
Returns
Boolean

Definition at line 397 of file SaveController.php.

◆ checkFile()

checkFile ( ObjectId  $oid,
  $valueName,
  $filename,
  $mimeType = null 
)
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
$oidThe ObjectId of the object
$valueNameThe name of the value of the object identified by oid
$filenameThe name of the file to upload (including path)
$mimeTypeThe 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()

getUploadFilename ( ObjectId  $oid,
  $valueName,
  $filename 
)
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
$oidThe ObjectId of the object
$valueNameThe name of the value of the object identified by oid
$filenameThe name of the file to upload (including path)
Returns
The filename

Definition at line 424 of file SaveController.php.

◆ shouldOverride()

shouldOverride ( ObjectId  $oid,
  $valueName,
  $filename 
)
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
$oidThe ObjectId of the object
$valueNameThe name of the value of the object identified by oid
$filenameThe 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()

getUploadDir ( ObjectId  $oid,
  $valueName 
)
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
$oidThe ObjectId of the object which will hold the association to the file
$valueNameThe name of the value which will hold the association to the file
Returns
The directory name

Definition at line 451 of file SaveController.php.