本文整理匯總了PHP中Preference::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Preference::setName方法的具體用法?PHP Preference::setName怎麽用?PHP Preference::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Preference
的用法示例。
在下文中一共展示了Preference::setName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeSavePreferences
public function executeSavePreferences()
{
sfLoader::loadHelpers('I18N');
$criteria = new Criteria();
$criteria->add(PreferencePeer::USER_ID, $this->getUser()->getId());
$preferences = PreferencePeer::doSelect($criteria);
foreach ($preferences as $preference) {
$preference->delete();
}
$this->msg = __('Preferences saved.');
if (($preference = $this->getUser()->getPreference('box_user')) != sfConfig::get('app_preference_box_user')) {
$this->msg .= "\napp_preference_box_user : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_user');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_snippets')) != sfConfig::get('app_preference_box_snippets')) {
$this->msg .= "\napp_preference_box_snippets : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_snippets');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_language_cloud')) != sfConfig::get('app_preference_box_language_cloud')) {
$this->msg .= "\napp_preference_box_language_cloud : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_language_cloud');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_tag_cloud')) != sfConfig::get('app_preference_box_tag_cloud')) {
$this->msg .= "\napp_preference_box_tag_cloud : " . ($preference == 'none' ? __('do not display') : __('display'));
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_tag_cloud');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_snippets_size')) != sfConfig::get('app_preference_box_snippets_size')) {
$this->msg .= "\napp_preference_box_snippets_size : " . $preference;
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_snippets_size');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('search_size')) != sfConfig::get('app_preference_search_size')) {
$this->msg .= "\napp_preference_search_size : " . $preference;
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_search_size');
$p->setValue($preference);
$p->save();
}
if (($preference = $this->getUser()->getPreference('box_order')) != sfConfig::get('app_preference_box_order')) {
$order_str = "";
foreach ($preference as $order_no) {
$order_str .= "{$order_no}, ";
}
$order_str = substr($order_str, 0, strlen($order_str) - 2);
$p = new Preference();
$p->setUserId($this->getUser()->getId());
$p->setName('box_order');
$p->setValue($order_str);
$p->save();
$this->msg .= "\napp_preference_box_order : " . $order_str;
}
}