Behavior configuration optionsΒΆ
This is a list of all the available configuration options which can be passed in under each field in your behavior configuration.
pathProcessor
: Returns a ProcessorInterface class name.- Default: (string)
Josegonzalez\Upload\File\Path\DefaultProcessor
- Default: (string)
writer
: Returns a WriterInterface class name.- Default: (string)
Josegonzalez\Upload\File\Writer\DefaultWriter
- Default: (string)
transformer
: Returns a TransformerInterface class name. Can also be a PHP callable.- Default: (string)
Josegonzalez\Upload\File\Transformer\DefaultTransformer
- Default: (string)
path
: A path relative to thefilesystem.root
.- Default: (string)
'webroot{DS}files{DS}{model}{DS}{field}{DS}'
- Tokens:
- {DS}: Replaced by a
DIRECTORY_SEPARATOR
- {model}: Replaced by the Table-alias() method.
- {table}: Replaced by the Table->table() method.
- {field}: Replaced by the name of the field which will store the upload filename.
- {field-value:(w+)}: Replaced by value contained in the
current entity in the specified field. As an example, if
your path has
{field-value:unique_id}
and the entity being saved has a value of4b3403665fea6
for the fieldunique_id
, then{field-value:unique_id}
will be replaced with4b3403665fea6
. This replacement can be used multiple times for one or more fields. If the value is not a string or zero-length, a LogicException will be thrown. - {primaryKey}: Replaced by the entity primary key, when available. If used on a new record being created, a LogicException will be thrown.
- {year}: Replaced by
date('Y')
- {month}: Replaced by
date('m')
- {day}: Replaced by
date('d')
- {time}: Replaced by
time()
- {microtime}: Replaced by
microtime()
- {DS}: Replaced by a
- Default: (string)
fields
: An array of fields to use when uploading files- Options:
fields.dir
: (defaultdir
) Field to use for storing the directoryfields.type
: (defaulttype
) Field to use for storing the filetypefields.size
: (defaultsize
) Field to use for storing the filesize
- Options:
filesystem
: An array of configuration info for configuring the writerIf using the DefaultWriter, the following options are available:
- Options:
filesystem.root
: (defaultROOT . DS
) Directory where files should be written to by defaultfilesystem.adapter
: (default Local Flysystem Adapter) A Flysystem-compatible adapter. Can also be a callable that returns an adapter.
- Options:
nameCallback
: A callable that can be used by the default pathProcessor to rename a file. Only handles original file naming.- Default:
NULL
- Available arguments:
array $data
: The upload dataarray $settings
: UploadBehavior settings for the current field
- Return: (string) the new name for the file
- Default:
keepFilesOnDelete
: Keep all files when deleting a record.- Default: (boolean)
true
- Default: (boolean)
restoreValueOnFailure
: Restores original value of the current field when uploaded file has error- Defaults: (boolean)
true
- Defaults: (boolean)