modules/media/models/Media.php
public function beforeSave($insert)
    {
        if (parent::beforeSave($insert)) {
            if ($this->isNewRecord) {
                $this->createTitle();
            }

            return true;
        }
        return false;
    }
public function beforeSave($insert)
    {
        if (parent::beforeSave($insert)) {
            if ($this->isNewRecord) {
                $this->createTitle();
            }

            return true;
        }
        return false;
    }
Actions to be taken before saving the record.
@param bool $insert
@return bool whether the record can be saved