本文整理汇总了PHP中Summit::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Summit::save方法的具体用法?PHP Summit::save怎么用?PHP Summit::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Summit
的用法示例。
在下文中一共展示了Summit::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeAddroute
public function executeAddroute()
{
$id = $this->getRequestParameter('document_id');
// check if a summit is already associated to hut. if not, create it
$create_summit = Association::countMains($id, 'sh') == 0;
if ($create_summit) {
$document = Document::find('Hut', $id, array('elevation', 'geom_wkt'));
$conn = sfDoctrine::Connection();
try {
$conn->beginTransaction();
// create first version of document, with culture and geometry of hut document
$hut_elevation = $document['elevation'];
$hut_lat = $document['lat'];
$hut_lon = $document['lon'];
$hut_culture = $document->getCulture();
$hut_name = $document['name'];
$history_metadata = new HistoryMetadata();
$history_metadata->setComment($this->__('Created summit synchronized with hut for access'));
$history_metadata->set('is_minor', false);
$history_metadata->set('user_id', 2);
// C2C user
$history_metadata->save();
$summit = new Summit();
$summit->setCulture($hut_culture);
$summit->set('name', $hut_name);
$summit->set('elevation', $hut_elevation);
$summit->set('summit_type', 100);
// set summit type to ' hut'
$summit->set('lat', $hut_lat);
$summit->set('lon', $hut_lon);
$summit->save();
$conn->commit();
// add others culture versions
foreach ($document->get('HutI18n') as $i18n) {
$culture = $i18n->getCulture();
if ($culture != $hut_culture) {
$conn->beginTransaction();
$hut_name = $i18n->getName();
$history_metadata = new HistoryMetadata();
$history_metadata->setComment($this->__('Created summit synchronized with hut for access'));
$history_metadata->set('is_minor', false);
$history_metadata->set('user_id', 2);
// C2C user
$history_metadata->save();
$summit->setCulture($culture);
$summit->set('name', $hut_name);
$summit->save();
$conn->commit();
}
}
} catch (Exception $e) {
$conn->rollback();
return $this->setErrorAndRedirect($this->__('Failed to create synchronized summit'), "routes/edit?link={$summit_id}");
}
$summit_id = $summit->get('id');
// get all associated regions (3+maps) with this hut:
$associations = GeoAssociation::findAllAssociations($id, array('dr', 'dc', 'dd', 'dv', 'dm'));
// replicate them with summit_id instead of id:
foreach ($associations as $ea) {
$a = new GeoAssociation();
$a->doSaveWithValues($summit_id, $ea->get('linked_id'), $ea->get('type'));
}
// associate hut to summit
$asso = new Association();
$asso->doSaveWithValues($summit_id, $id, 'sh', 2);
// C2C user
} else {
$associations = Association::findAllAssociations($id, 'sh');
$summit_id = $associations[0]->get('main_id');
}
$this->clearCache('huts', $id);
return $this->redirect("routes/edit?link={$summit_id}");
}