protected function beforeInsert(&$to_insert = null) { if (array_key_exists('parent_id', $to_insert) && !$to_insert['parent_id']) { $to_insert['parent_id'] = null; } if (array_key_exists('parent_id', $to_insert)) { $parent = $this->getId($to_insert['parent_id']); } else { $parent = null; } $to_insert['hierarchy'] = $parent ? $parent->hierarchy . '/' . $parent->id : ''; if (!isset($to_insert['is_folder']) || !$to_insert['is_folder']) { $to_insert['infos'] = $this->infos['file']; $to_insert['name'] = $this->infos['file']['file_name']; $to_insert['type'] = $this->infos['file']['file_type']; } else { $to_insert['file'] = null; $to_insert['infos'] = null; } parent::beforeInsert($to_insert); }
protected function beforeInsert(&$to_insert = null) { parent::beforeInsert($to_insert); $to_insert['password'] = password_hash($to_insert['password'], PASSWORD_DEFAULT); }