PHP Class Josegonzalez\Upload\Model\Behavior\UploadBehavior

Inheritance: extends Cake\ORM\Behavior
Afficher le fichier Open project: josegonzalez/cakephp-upload Class Usage Examples

Méthodes publiques

Méthode Description
afterDelete ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void | false Deletes the files after the entity is deleted
beforeMarshal ( Cake\Event\Event $event, ArrayObject $data, ArrayObject $options ) : void Modifies the data being marshalled to ensure invalid upload data is not inserted
beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void | false Modifies the entity before it is saved so that uploaded file data is persisted in the database too.
constructFiles ( Cake\ORM\Entity $entity, array $data, string $field, array $settings, string $basepath ) : array Creates a set of files from the initial data and returns them as key/value pairs, where the path on disk maps to name which each file should have.
getPathProcessor ( Cake\ORM\Entity $entity, array $data, string $field, array $settings ) : Josegonzalez\Upload\File\Path\AbstractProcessor Retrieves an instance of a path processor which knows how to build paths for a given file upload
getWriter ( Cake\ORM\Entity $entity, array $data, string $field, array $settings ) : Josegonzalez\Upload\File\Path\AbstractProcessor Retrieves an instance of a file writer which knows how to write files to disk
initialize ( array $config ) : void Initialize hook

Method Details

afterDelete() public méthode

Deletes the files after the entity is deleted
public afterDelete ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void | false
$event Cake\Event\Event The afterDelete event that was fired
$entity Cake\ORM\Entity The entity that was deleted
$options ArrayObject the options passed to the delete method
Résultat void | false

beforeMarshal() public méthode

Modifies the data being marshalled to ensure invalid upload data is not inserted
public beforeMarshal ( Cake\Event\Event $event, ArrayObject $data, ArrayObject $options ) : void
$event Cake\Event\Event an event instance
$data ArrayObject data being marshalled
$options ArrayObject options for the current event
Résultat void

beforeSave() public méthode

Modifies the entity before it is saved so that uploaded file data is persisted in the database too.
public beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void | false
$event Cake\Event\Event The beforeSave event that was fired
$entity Cake\ORM\Entity The entity that is going to be saved
$options ArrayObject the options passed to the save method
Résultat void | false

constructFiles() public méthode

This is done through an intermediate transformer, which should return said array. Example: [ '/tmp/path/to/file/on/disk' => 'file.pdf', '/tmp/path/to/file/on/disk-2' => 'file-preview.png', ] A user can specify a callable in the transformer setting, which can be used to construct this key/value array. This processor can be used to create the source files.
public constructFiles ( Cake\ORM\Entity $entity, array $data, string $field, array $settings, string $basepath ) : array
$entity Cake\ORM\Entity an entity
$data array the data being submitted for a save
$field string the field for which data will be saved
$settings array the settings for the current field
$basepath string a basepath where the files are written to
Résultat array key/value pairs of temp files mapping to their names

getPathProcessor() public méthode

Retrieves an instance of a path processor which knows how to build paths for a given file upload
public getPathProcessor ( Cake\ORM\Entity $entity, array $data, string $field, array $settings ) : Josegonzalez\Upload\File\Path\AbstractProcessor
$entity Cake\ORM\Entity an entity
$data array the data being submitted for a save
$field string the field for which data will be saved
$settings array the settings for the current field
Résultat Josegonzalez\Upload\File\Path\AbstractProcessor

getWriter() public méthode

Retrieves an instance of a file writer which knows how to write files to disk
public getWriter ( Cake\ORM\Entity $entity, array $data, string $field, array $settings ) : Josegonzalez\Upload\File\Path\AbstractProcessor
$entity Cake\ORM\Entity an entity
$data array the data being submitted for a save
$field string the field for which data will be saved
$settings array the settings for the current field
Résultat Josegonzalez\Upload\File\Path\AbstractProcessor

initialize() public méthode

Initialize hook
public initialize ( array $config ) : void
$config array The config for this behavior.
Résultat void