• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang scope.NewPerm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/corestoreio/csfw/config/scope.NewPerm函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPerm函数的具体用法?Golang NewPerm怎么用?Golang NewPerm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewPerm函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestGroupSliceMerge

func TestGroupSliceMerge(t *testing.T) {

	tests := []struct {
		have    []*config.Group
		wantErr error
		want    string
	}{
		{
			have: []*config.Group{
				{
					ID: "b",
					Fields: config.FieldSlice{
						&config.Field{ID: "c", Default: `c`, Type: config.TypeMultiselect},
					},
				},
				{
					ID: "b",
					Fields: config.FieldSlice{
						&config.Field{ID: "d", Default: `d`, Comment: "Ring of fire", Type: config.TypeObscure},
						&config.Field{ID: "c", Default: `haha`, Type: config.TypeSelect, Scope: scope.NewPerm(scope.DefaultID, scope.WebsiteID)},
					},
				},
				{
					ID: "b",
					Fields: config.FieldSlice{
						&config.Field{ID: "d", Default: `overriddenD`, Label: "Sect2Group2Label4", Comment: "LOTR"},
						&config.Field{ID: "c", Default: `overriddenHaha`, Type: config.TypeHidden},
					},
				},
			},
			wantErr: nil,
			want:    `[{"ID":"b","Fields":[{"ID":"c","Type":"hidden","Scope":["Default","Website"],"Default":"overriddenHaha"},{"ID":"d","Type":"obscure","Label":"Sect2Group2Label4","Comment":"LOTR","Default":"overriddenD"}]}]` + "\n",
		},
		{
			have:    nil,
			wantErr: nil,
			want:    `null` + "\n",
		},
	}

	for i, test := range tests {
		var baseGsl config.GroupSlice
		haveErr := baseGsl.Merge(test.have...)
		if test.wantErr != nil {
			assert.Len(t, baseGsl, 0)
			assert.Error(t, haveErr)
			assert.Contains(t, haveErr.Error(), test.wantErr)
		} else {
			assert.NoError(t, haveErr)
			j := baseGsl.ToJSON()
			if j != test.want {
				t.Errorf("\nIndex: %d\nExpected: %s\nActual:   %s\n", i, test.want, j)
			}
		}
	}
}
开发者ID:levcom,项目名称:csfw,代码行数:56,代码来源:elements_test.go


示例2:

			&config.Group{
				ID:        "ups",
				Label:     `UPS`,
				Comment:   ``,
				SortOrder: 100,
				Scope:     scope.PermAll,
				Fields: config.FieldSlice{
					&config.Field{
						// Path: `carriers/ups/access_license_number`,
						ID:           "access_license_number",
						Label:        `Access License Number`,
						Comment:      ``,
						Type:         config.TypeObscure,
						SortOrder:    30,
						Visible:      config.VisibleYes,
						Scope:        scope.NewPerm(scope.DefaultID, scope.WebsiteID),
						Default:      nil,
						BackendModel: nil, // Magento\Config\Model\Config\Backend\Encrypted // @todo Magento\Config\Model\Config\Backend\Encrypted
						SourceModel:  nil,
					},

					&config.Field{
						// Path: `carriers/ups/active`,
						ID:           "active",
						Label:        `Enabled for Checkout`,
						Comment:      ``,
						Type:         config.TypeSelect,
						SortOrder:    10,
						Visible:      config.VisibleYes,
						Scope:        scope.NewPerm(scope.DefaultID, scope.WebsiteID),
						Default:      false,
开发者ID:levcom,项目名称:csfw,代码行数:31,代码来源:config_ups.go


示例3:

						Scope:        scope.PermAll,
						Default:      16,
						BackendModel: nil,
						SourceModel:  nil,
					},
				},
			},
		},
	},

	// Hidden Configuration, may be visible somewhere else ...
	&config.Section{
		ID: "general",
		Groups: config.GroupSlice{
			&config.Group{
				ID: "validator_data",
				Fields: config.FieldSlice{
					&config.Field{
						// Path: `general/validator_data/input_types`,
						ID:      "input_types",
						Type:    config.TypeHidden,
						Visible: config.VisibleNo,
						Scope:   scope.NewPerm(scope.DefaultID), // @todo search for that
						Default: `{"swatch_visual":"swatch_visual","swatch_text":"swatch_text"}`,
					},
				},
			},
		},
	},
)
开发者ID:levcom,项目名称:csfw,代码行数:30,代码来源:config_swatches.go


示例4:

	"github.com/corestoreio/csfw/config/scope"
)

var PackageConfiguration = config.NewConfiguration(
	&config.Section{
		ID:        "system",
		Label:     "",
		SortOrder: 0,
		Scope:     nil,
		Groups: config.GroupSlice{
			&config.Group{
				ID:        "backup",
				Label:     `Scheduled Backup Settings`,
				Comment:   ``,
				SortOrder: 500,
				Scope:     scope.NewPerm(scope.DefaultID),
				Fields: config.FieldSlice{
					&config.Field{
						// Path: `system/backup/enabled`,
						ID:           "enabled",
						Label:        `Enable Scheduled Backup`,
						Comment:      ``,
						Type:         config.TypeSelect,
						SortOrder:    10,
						Visible:      config.VisibleYes,
						Scope:        scope.NewPerm(scope.DefaultID),
						Default:      nil,
						BackendModel: nil,
						SourceModel:  nil, // Magento\Config\Model\Config\Source\Yesno
					},
开发者ID:hafeez3000,项目名称:csfw,代码行数:30,代码来源:config_backup.go


示例5:

	"github.com/corestoreio/csfw/config/scope"
)

var PackageConfiguration = config.MustNewConfiguration(
	&config.Section{
		ID:        "sales",
		Label:     "",
		SortOrder: 0,
		Scope:     nil,
		Groups: config.GroupSlice{
			&config.Group{
				ID:        "msrp",
				Label:     `Minimum Advertised Price`,
				Comment:   ``,
				SortOrder: 110,
				Scope:     scope.NewPerm(scope.DefaultID, scope.WebsiteID),
				Fields: config.FieldSlice{
					&config.Field{
						// Path: `sales/msrp/enabled`,
						ID:           "enabled",
						Label:        `Enable MAP`,
						Comment:      `<strong style="color:red">Warning!</strong> Enabling MAP by default will hide all product prices on Storefront.`,
						Type:         config.TypeSelect,
						SortOrder:    10,
						Visible:      config.VisibleYes,
						Scope:        scope.NewPerm(scope.DefaultID, scope.WebsiteID),
						Default:      false,
						BackendModel: nil,
						SourceModel:  nil, // Magento\Config\Model\Config\Source\Yesno
					},
开发者ID:levcom,项目名称:csfw,代码行数:30,代码来源:config_msrp.go


示例6: init

func init() {
	PackageConfiguration = config.MustNewConfiguration(
		&config.Section{
			ID:        "general",
			Label:     "General",
			SortOrder: 10,
			Scope:     scope.PermAll,

			Groups: config.GroupSlice{
				&config.Group{
					ID:        "single_store_mode",
					Label:     `Single-Store Mode`,
					Comment:   ``,
					SortOrder: 150,
					Scope:     scope.NewPerm(scope.DefaultID),
					Fields: config.FieldSlice{
						&config.Field{
							// Path: `general/single_store_mode/enabled`,
							ID:           "enabled",
							Label:        `Enable Single-Store Mode`,
							Comment:      `This setting will not be taken into account if system has more than one store view.`,
							Type:         config.TypeSelect,
							SortOrder:    10,
							Visible:      config.VisibleYes,
							Scope:        scope.NewPerm(scope.DefaultID),
							Default:      nil,
							BackendModel: nil,
							SourceModel:  configsource.YesNo, // Magento\Config\Model\Config\Source\Yesno
						},
					},
				},

				&config.Group{
					ID:        "store_information",
					Label:     `Store Information`,
					Comment:   ``,
					SortOrder: 100,
					Scope:     scope.PermAll,
					Fields: config.FieldSlice{
						&config.Field{
							// Path: `general/store_information/name`,
							ID:           "name",
							Label:        `Store Name`,
							Comment:      ``,
							Type:         config.TypeText,
							SortOrder:    10,
							Visible:      config.VisibleYes,
							Scope:        scope.PermAll,
							Default:      nil,
							BackendModel: nil,
							SourceModel:  nil,
						},

						&config.Field{
							// Path: `general/store_information/phone`,
							ID:           "phone",
							Label:        `Store Phone Number`,
							Comment:      ``,
							Type:         config.TypeText,
							SortOrder:    20,
							Visible:      config.VisibleYes,
							Scope:        scope.PermAll,
							Default:      nil,
							BackendModel: nil,
							SourceModel:  nil,
						},
					},
				},
			},
		},

		&config.Section{
			ID:        "web",
			Label:     "Web",
			SortOrder: 20,
			Scope:     scope.PermAll,
			Groups: config.GroupSlice{
				&config.Group{
					ID:        "url",
					Label:     `Url Options`,
					Comment:   ``,
					SortOrder: 3,
					Scope:     scope.NewPerm(scope.DefaultID),
					Fields: config.FieldSlice{
						&config.Field{
							// Path: `web/url/use_store`,
							ID:           "use_store",
							Label:        `Add Store Code to Urls`,
							Comment:      `<strong style="color:red">Warning!</strong> When using Store Code in URLs, in some cases system may not work properly if URLs without Store Codes are specified in the third party services (e.g. PayPal etc.).`,
							Type:         config.TypeSelect,
							SortOrder:    10,
							Visible:      config.VisibleYes,
							Scope:        scope.NewPerm(scope.DefaultID),
							Default:      nil,
							BackendModel: nil,                // Magento\Config\Model\Config\Backend\Store
							SourceModel:  configsource.YesNo, // Magento\Config\Model\Config\Source\Yesno
						},

						&config.Field{
							// Path: `web/url/redirect_to_base`,
//.........这里部分代码省略.........
开发者ID:levcom,项目名称:csfw,代码行数:101,代码来源:config.go


示例7: init

func init() {
	PackageConfiguration = config.NewConfiguration(
		&config.Section{
			ID:        "currency",
			Label:     "Currency Setup",
			SortOrder: 60,
			Scope:     scope.PermAll,
			Groups: config.GroupSlice{
				&config.Group{
					ID:        "options",
					Label:     `Currency Options`,
					Comment:   ``,
					SortOrder: 30,
					Scope:     scope.PermAll,
					Fields: config.FieldSlice{
						&config.Field{
							// Path: `currency/options/base`,
							ID:           "base",
							Label:        `Base Currency`,
							Comment:      `Base currency is used for all online payment transactions. If you have more than one store view, the base currency scope is defined by the catalog price scope ("Catalog" > "Price" > "Catalog Price Scope").`,
							Type:         config.TypeSelect,
							SortOrder:    1,
							Visible:      config.VisibleYes,
							Scope:        scope.NewPerm(scope.DefaultID, scope.WebsiteID),
							Default:      `USD`,
							BackendModel: nil, // Magento\Config\Model\Config\Backend\Currency\Base
							SourceModel:  nil, // Magento\Config\Model\Config\Source\Locale\Currency
						},

						&config.Field{
							// Path: `currency/options/default`,
							ID:           "default",
							Label:        `Default Display Currency`,
							Comment:      ``,
							Type:         config.TypeSelect,
							SortOrder:    2,
							Visible:      config.VisibleYes,
							Scope:        scope.PermAll,
							Default:      `USD`,
							BackendModel: nil, // Magento\Config\Model\Config\Backend\Currency\DefaultCurrency
							SourceModel:  nil, // Magento\Config\Model\Config\Source\Locale\Currency
						},

						&config.Field{
							// Path: `currency/options/allow`,
							ID:           "allow",
							Label:        `Allowed Currencies`,
							Comment:      ``,
							Type:         config.TypeMultiselect,
							SortOrder:    3,
							Visible:      config.VisibleYes,
							Scope:        scope.PermAll,
							Default:      `USD,EUR`,
							BackendModel: nil, // Magento\Config\Model\Config\Backend\Currency\Allow
							SourceModel:  nil, // Magento\Config\Model\Config\Source\Locale\Currency
						},
					},
				},

				&config.Group{
					ID:        "webservicex",
					Label:     `Webservicex`,
					Comment:   ``,
					SortOrder: 40,
					Scope:     scope.NewPerm(scope.DefaultID),
					Fields: config.FieldSlice{
						&config.Field{
							// Path: `currency/webservicex/timeout`,
							ID:           "timeout",
							Label:        `Connection Timeout in Seconds`,
							Comment:      ``,
							Type:         config.TypeText,
							SortOrder:    0,
							Visible:      config.VisibleYes,
							Scope:        scope.NewPerm(scope.DefaultID),
							Default:      100,
							BackendModel: nil,
							SourceModel:  nil,
						},
					},
				},

				&config.Group{
					ID:        "import",
					Label:     `Scheduled Import Settings`,
					Comment:   ``,
					SortOrder: 50,
					Scope:     scope.NewPerm(scope.DefaultID),
					Fields: config.FieldSlice{
						&config.Field{
							// Path: `currency/import/enabled`,
							ID:           "enabled",
							Label:        `Enabled`,
							Comment:      ``,
							Type:         config.TypeSelect,
							SortOrder:    1,
							Visible:      config.VisibleYes,
							Scope:        scope.PermAll,
							Default:      false,
							BackendModel: nil,
//.........这里部分代码省略.........
开发者ID:hafeez3000,项目名称:csfw,代码行数:101,代码来源:config.go


示例8:

	"github.com/corestoreio/csfw/config/scope"
)

var PackageConfiguration = config.NewConfiguration(
	&config.Section{
		ID:        "customer",
		Label:     "",
		SortOrder: 130,
		Scope:     scope.PermAll,
		Groups: config.GroupSlice{
			&config.Group{
				ID:        "online_customers",
				Label:     `Online Customers Options`,
				Comment:   ``,
				SortOrder: 10,
				Scope:     scope.NewPerm(config.IDScopeDefault),
				Fields: config.FieldSlice{
					&config.Field{
						// Path: `customer/online_customers/online_minutes_interval`,
						ID:           "online_minutes_interval",
						Label:        `Online Minutes Interval`,
						Comment:      `Leave empty for default (15 minutes).`,
						Type:         config.TypeText,
						SortOrder:    1,
						Visible:      config.VisibleYes,
						Scope:        scope.NewPerm(config.IDScopeDefault),
						Default:      nil,
						BackendModel: nil,
						SourceModel:  nil,
					},
				},
开发者ID:hafeez3000,项目名称:csfw,代码行数:31,代码来源:config_log.go


示例9:

	"github.com/corestoreio/csfw/config/scope"
)

var PackageConfiguration = config.MustNewConfiguration(
	&config.Section{
		ID:        "payment_services",
		Label:     "Payment Services",
		SortOrder: 450,
		Scope:     scope.PermAll,
		Groups: config.GroupSlice{
			&config.Group{
				ID:        "centinel",
				Label:     `3D Secure Credit Card Validation`,
				Comment:   ``,
				SortOrder: 1,
				Scope:     scope.NewPerm(config.IDScopeDefault, config.IDScopeWebsite),
				Fields: config.FieldSlice{
					&config.Field{
						// Path: `payment_services/centinel/processor_id`,
						ID:           "processor_id",
						Label:        `Processor ID`,
						Comment:      ``,
						Type:         config.TypeText,
						SortOrder:    10,
						Visible:      config.VisibleYes,
						Scope:        scope.NewPerm(config.IDScopeDefault, config.IDScopeWebsite),
						Default:      nil,
						BackendModel: nil,
						SourceModel:  nil,
					},
开发者ID:levcom,项目名称:csfw,代码行数:30,代码来源:config_centinel.go


示例10: TestSectionSliceMerge

func TestSectionSliceMerge(t *testing.T) {

	// Got stuck in comparing JSON?
	// Use a Webservice to compare the JSON output!

	tests := []struct {
		have    []config.SectionSlice
		wantErr string
		want    string
		wantLen int
	}{
		0: {
			have: []config.SectionSlice{
				nil,
				{
					nil,
					&config.Section{
						ID: "a",
						Groups: config.GroupSlice{
							nil,
							&config.Group{
								ID: "b",
								Fields: config.FieldSlice{
									&config.Field{ID: "c", Default: `c`},
								},
							},
							&config.Group{
								ID: "b",
								Fields: config.FieldSlice{
									&config.Field{ID: "d", Default: `d`},
								},
							},
						},
					},
				},
				{
					&config.Section{ID: "a", Label: "LabelA", Groups: nil},
				},
			},
			wantErr: "",
			want:    `[{"ID":"a","Label":"LabelA","Groups":[{"ID":"b","Fields":[{"ID":"c","Default":"c"},{"ID":"d","Default":"d"}]}]}]` + "\n",
			wantLen: 2,
		},
		1: {
			have: []config.SectionSlice{
				{
					&config.Section{
						ID:    "a",
						Label: "SectionLabelA",
						Groups: config.GroupSlice{
							&config.Group{
								ID:    "b",
								Scope: scope.NewPerm(scope.DefaultID),
								Fields: config.FieldSlice{
									&config.Field{ID: "c", Default: `c`},
								},
							},
							nil,
						},
					},
				},
				{
					&config.Section{
						ID:    "a",
						Scope: scope.NewPerm(scope.DefaultID, scope.WebsiteID),
						Groups: config.GroupSlice{
							&config.Group{ID: "b", Label: "GroupLabelB1"},
							nil,
							&config.Group{ID: "b", Label: "GroupLabelB2"},
							&config.Group{
								ID: "b2",
								Fields: config.FieldSlice{
									&config.Field{ID: "d", Default: `d`},
								},
							},
						},
					},
				},
			},
			wantErr: "",
			want:    `[{"ID":"a","Label":"SectionLabelA","Scope":["Default","Website"],"Groups":[{"ID":"b","Label":"GroupLabelB2","Scope":["Default"],"Fields":[{"ID":"c","Default":"c"}]},{"ID":"b2","Fields":[{"ID":"d","Default":"d"}]}]}]` + "\n",
			wantLen: 2,
		},
		2: {
			have: []config.SectionSlice{
				{
					&config.Section{ID: "a", Label: "SectionLabelA", SortOrder: 20, Permission: 22},
				},
				{
					&config.Section{ID: "a", Scope: scope.NewPerm(scope.DefaultID, scope.WebsiteID), SortOrder: 10, Permission: 3},
				},
			},
			wantErr: "",
			want:    `[{"ID":"a","Label":"SectionLabelA","Scope":["Default","Website"],"SortOrder":10,"Permission":3,"Groups":null}]` + "\n",
		},
		3: {
			have: []config.SectionSlice{
				{
					&config.Section{
						ID:    "a",
//.........这里部分代码省略.........
开发者ID:levcom,项目名称:csfw,代码行数:101,代码来源:elements_test.go



注:本文中的github.com/corestoreio/csfw/config/scope.NewPerm函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang scope.Option类代码示例发布时间:2022-05-23
下一篇:
Golang scope.MockID函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap