/** * Ensures a top level folder exists that matches the model. * * @param AssetSourceModel $model * * @return int */ public function ensureTopFolder(AssetSourceModel $model) { $folder = AssetFolderRecord::model()->findByAttributes(array('name' => $model->name, 'sourceId' => $model->id)); if (empty($folder)) { $folder = new AssetFolderRecord(); $folder->sourceId = $model->id; $folder->parentId = null; $folder->name = $model->name; $folder->path = ''; $folder->save(); } return $folder->id; }
/** * Delete a folder record by id. * * @param $folderId * * @return bool */ public function deleteFolderRecord($folderId) { return (bool) AssetFolderRecord::model()->deleteAll('id = :folderId', array(':folderId' => $folderId)); }