/**
  * Populates an element model based on a query result.
  *
  * @param array $row
  * @return array
  */
 public function populateElementModel($row)
 {
     return Shortlist_ListModel::populateModel($row);
 }
 public function saveList(Shortlist_ListModel $list)
 {
     $listRecord = Shortlist_ListRecord::model()->findById($list->id);
     if (!$listRecord) {
         throw new Exception(Craft::t('No list exists with the ID “{id}”', array('id' => $list->id)));
     }
     $listRecord->validate();
     $list->addErrors($listRecord->getErrors());
     if (!$list->hasErrors()) {
         $transaction = craft()->db->getCurrentTransaction() === null ? craft()->db->beginTransaction() : null;
         try {
             if (craft()->elements->saveElement($list)) {
                 $listRecord->save(false);
                 if ($transaction !== null) {
                     $transaction->commit();
                 }
                 return true;
             }
         } catch (\Exception $e) {
             if ($transaction !== null) {
                 $transaction->rollback();
             }
             throw $e;
         }
     }
     return false;
 }