public function beforeSave() { if (!$this->getAttribute('_id')) { if (!Context::getKey()->isServer()) { throw new ForbiddenException("Need a 'server' key to perform this action."); } if (!$this->getAttribute('message')) { throw new InternalException("Can't create PushMessage: 'message' is required."); } $this->setAttribute('status', self::STATUS_QUEUE); $this->setAttribute('devices', 0); $this->setAttribute('failure', 0); } parent::beforeSave(); }
public function beforeSave() { // Upload/relate each file attachment on the collection. if ($this->hasAttachedFiles()) { $this->uploadAttachedFiles(); } return parent::beforeSave(); }