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 |
return | void | false |
/** * Every time the image is saved, the file is renamed. This eliminate the * need to handle cache busting in the browser. * * @param \Cake\Event\Event $event The beforeSave event that was fired * @param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved * @param \ArrayObject $options the options passed to the save method * @return void */ public function beforeSave(Event $event, Entity $entity, ArrayObject $options) { $entity->set('uniqid', uniqid()); parent::beforeSave($event, $entity, $options); }