func (pp *PkgBackend) init(cfgStruct element.SectionSlice) *PkgBackend {
	pp.Lock()
	defer pp.Unlock()
	pp.TransEmailIdentCustom1Email = model.NewStr(`trans_email/ident_custom1/email`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentCustom1Name = model.NewStr(`trans_email/ident_custom1/name`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentCustom2Email = model.NewStr(`trans_email/ident_custom2/email`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentCustom2Name = model.NewStr(`trans_email/ident_custom2/name`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentGeneralEmail = model.NewStr(`trans_email/ident_general/email`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentGeneralName = model.NewStr(`trans_email/ident_general/name`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentSalesEmail = model.NewStr(`trans_email/ident_sales/email`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentSalesName = model.NewStr(`trans_email/ident_sales/name`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentSupportEmail = model.NewStr(`trans_email/ident_support/email`, model.WithConfigStructure(cfgStruct))
	pp.TransEmailIdentSupportName = model.NewStr(`trans_email/ident_support/name`, model.WithConfigStructure(cfgStruct))
	pp.DesignThemeThemeID = model.NewStr(`design/theme/theme_id`, model.WithConfigStructure(cfgStruct))
	pp.DesignThemeUaRegexp = model.NewStr(`design/theme/ua_regexp`, model.WithConfigStructure(cfgStruct))
	pp.DesignPaginationPaginationFrame = model.NewStr(`design/pagination/pagination_frame`, model.WithConfigStructure(cfgStruct))
	pp.DesignPaginationPaginationFrameSkip = model.NewStr(`design/pagination/pagination_frame_skip`, model.WithConfigStructure(cfgStruct))
	pp.DesignPaginationAnchorTextForPrevious = model.NewStr(`design/pagination/anchor_text_for_previous`, model.WithConfigStructure(cfgStruct))
	pp.DesignPaginationAnchorTextForNext = model.NewStr(`design/pagination/anchor_text_for_next`, model.WithConfigStructure(cfgStruct))
	pp.DevDebugTemplateHintsStorefront = model.NewBool(`dev/debug/template_hints_storefront`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevDebugTemplateHintsAdmin = model.NewBool(`dev/debug/template_hints_admin`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevDebugTemplateHintsBlocks = model.NewBool(`dev/debug/template_hints_blocks`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevTemplateAllowSymlink = model.NewBool(`dev/template/allow_symlink`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevTemplateMinifyHTML = model.NewBool(`dev/template/minify_html`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevTranslateInlineActive = model.NewBool(`dev/translate_inline/active`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevTranslateInlineActiveAdmin = model.NewBool(`dev/translate_inline/active_admin`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevJsMergeFiles = model.NewBool(`dev/js/merge_files`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevJsEnableJsBundling = model.NewBool(`dev/js/enable_js_bundling`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevJsMinifyFiles = model.NewBool(`dev/js/minify_files`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevCSSMergeCSSFiles = model.NewBool(`dev/css/merge_css_files`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevCSSMinifyFiles = model.NewBool(`dev/css/minify_files`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.DevImageDefaultAdapter = model.NewStr(`dev/image/default_adapter`, model.WithConfigStructure(cfgStruct))
	pp.DevStaticSign = model.NewBool(`dev/static/sign`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.GeneralStoreInformationName = model.NewStr(`general/store_information/name`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationPhone = model.NewStr(`general/store_information/phone`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationHours = model.NewStr(`general/store_information/hours`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationCountryID = model.NewStr(`general/store_information/country_id`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationRegionID = model.NewStr(`general/store_information/region_id`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationPostcode = model.NewStr(`general/store_information/postcode`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationCity = model.NewStr(`general/store_information/city`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationStreetLine1 = model.NewStr(`general/store_information/street_line1`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationStreetLine2 = model.NewStr(`general/store_information/street_line2`, model.WithConfigStructure(cfgStruct))
	pp.GeneralStoreInformationMerchantVatNumber = model.NewStr(`general/store_information/merchant_vat_number`, model.WithConfigStructure(cfgStruct))
	pp.GeneralSingleStoreModeEnabled = model.NewBool(`general/single_store_mode/enabled`, model.WithConfigStructure(cfgStruct), model.WithSource(source.EnableDisable))
	pp.SystemSMTPDisable = model.NewBool(`system/smtp/disable`, model.WithConfigStructure(cfgStruct), model.WithSource(source.EnableDisable))
	pp.SystemSMTPHost = model.NewStr(`system/smtp/host`, model.WithConfigStructure(cfgStruct))
	pp.SystemSMTPPort = model.NewStr(`system/smtp/port`, model.WithConfigStructure(cfgStruct))
	pp.SystemSMTPSetReturnPath = model.NewBool(`system/smtp/set_return_path`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.SystemSMTPReturnPathEmail = model.NewStr(`system/smtp/return_path_email`, model.WithConfigStructure(cfgStruct))
	pp.AdminEmailsForgotEmailTemplate = model.NewStr(`admin/emails/forgot_email_template`, model.WithConfigStructure(cfgStruct))
	pp.AdminEmailsForgotEmailIdentity = model.NewStr(`admin/emails/forgot_email_identity`, model.WithConfigStructure(cfgStruct))
	pp.AdminEmailsPasswordResetLinkExpirationPeriod = model.NewStr(`admin/emails/password_reset_link_expiration_period`, model.WithConfigStructure(cfgStruct))
	pp.AdminStartupMenuItemID = model.NewStr(`admin/startup/menu_item_id`, model.WithConfigStructure(cfgStruct))
	pp.AdminURLUseCustom = model.NewBool(`admin/url/use_custom`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.AdminURLCustom = model.NewStr(`admin/url/custom`, model.WithConfigStructure(cfgStruct))
	pp.AdminURLUseCustomPath = model.NewBool(`admin/url/use_custom_path`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.AdminURLCustomPath = model.NewStr(`admin/url/custom_path`, model.WithConfigStructure(cfgStruct))
	pp.AdminSecurityUseFormKey = model.NewBool(`admin/security/use_form_key`, model.WithConfigStructure(cfgStruct))
	pp.AdminSecurityUseCaseSensitiveLogin = model.NewBool(`admin/security/use_case_sensitive_login`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.AdminSecuritySessionLifetime = model.NewStr(`admin/security/session_lifetime`, model.WithConfigStructure(cfgStruct))
	pp.AdminDashboardEnableCharts = model.NewBool(`admin/dashboard/enable_charts`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebURLUseStore = model.NewBool(`web/url/use_store`, model.WithConfigStructure(cfgStruct))
	pp.WebURLRedirectToBase = NewConfigRedirectToBase(`web/url/redirect_to_base`, model.WithConfigStructure(cfgStruct))
	pp.WebSeoUseRewrites = model.NewBool(`web/seo/use_rewrites`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebUnsecureBaseURL = model.NewBaseURL(`web/unsecure/base_url`, model.WithConfigStructure(cfgStruct))
	pp.WebUnsecureBaseLinkURL = model.NewBaseURL(`web/unsecure/base_link_url`, model.WithConfigStructure(cfgStruct))
	pp.WebUnsecureBaseStaticURL = model.NewBaseURL(`web/unsecure/base_static_url`, model.WithConfigStructure(cfgStruct))
	pp.WebUnsecureBaseMediaURL = model.NewBaseURL(`web/unsecure/base_media_url`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureBaseURL = model.NewBaseURL(`web/secure/base_url`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureBaseLinkURL = model.NewBaseURL(`web/secure/base_link_url`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureBaseStaticURL = model.NewBaseURL(`web/secure/base_static_url`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureBaseMediaURL = model.NewBaseURL(`web/secure/base_media_url`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureUseInFrontend = model.NewBool(`web/secure/use_in_frontend`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebSecureUseInAdminhtml = model.NewBool(`web/secure/use_in_adminhtml`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebSecureEnableHsts = model.NewBool(`web/secure/enable_hsts`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureEnableUpgradeInsecure = model.NewBool(`web/secure/enable_upgrade_insecure`, model.WithConfigStructure(cfgStruct))
	pp.WebSecureOffloaderHeader = model.NewStr(`web/secure/offloader_header`, model.WithConfigStructure(cfgStruct))
	pp.WebDefaultFront = model.NewStr(`web/default/front`, model.WithConfigStructure(cfgStruct))
	pp.WebDefaultNoRoute = model.NewStr(`web/default/no_route`, model.WithConfigStructure(cfgStruct))
	pp.WebSessionUseRemoteAddr = model.NewBool(`web/session/use_remote_addr`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebSessionUseHTTPVia = model.NewBool(`web/session/use_http_via`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebSessionUseHTTPXForwardedFor = model.NewBool(`web/session/use_http_x_forwarded_for`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebSessionUseHTTPUserAgent = model.NewBool(`web/session/use_http_user_agent`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))
	pp.WebSessionUseFrontendSid = model.NewBool(`web/session/use_frontend_sid`, model.WithConfigStructure(cfgStruct), model.WithSource(source.YesNo))

	return pp
}
Example #2
0
func TestBool(t *testing.T) {
	t.Parallel()
	wantPath := scope.StrWebsites.FQPathInt64(3, "web/cors/allow_credentials")
	b := model.NewBool("web/cors/allow_credentials", model.WithConfigStructure(configStructure), model.WithSource(source.YesNo))

	assert.Exactly(t, source.YesNo, b.Options())
	// because default value in packageConfiguration is "true"
	assert.True(t, b.Get(config.NewMockGetter().NewScoped(0, 0, 0)))

	assert.False(t, b.Get(config.NewMockGetter(
		config.WithMockValues(config.MockPV{
			wantPath: 0,
		}),
	).NewScoped(0, 0, 3)))

	mw := &config.MockWrite{}
	assert.EqualError(t, b.Write(mw, true, scope.StoreID, 3), "Scope permission insufficient: Have 'Store'; Want 'Default,Website'")
	assert.NoError(t, b.Write(mw, true, scope.WebsiteID, 3))
	assert.Exactly(t, wantPath, mw.ArgPath)
	assert.Exactly(t, "true", mw.ArgValue.(string))
}