PHP Класс Josegonzalez\Upload\Model\Behavior\UploadBehavior

Наследование: extends Cake\ORM\Behavior
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Описание методов

afterDelete() публичный Метод

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
Результат void | false

beforeMarshal() публичный Метод

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
Результат void

beforeSave() публичный Метод

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
Результат void | false

constructFiles() публичный Метод

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
Результат array key/value pairs of temp files mapping to their names

getPathProcessor() публичный Метод

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
Результат Josegonzalez\Upload\File\Path\AbstractProcessor

getWriter() публичный Метод

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
Результат Josegonzalez\Upload\File\Path\AbstractProcessor

initialize() публичный Метод

Initialize hook
public initialize ( array $config ) : void
$config array The config for this behavior.
Результат void