flamingo.me/flamingo-commerce/v3@v3.11.0/customer/module.go (about) 1 package customer 2 3 import ( 4 "flamingo.me/dingo" 5 "flamingo.me/flamingo/v3/core/auth" 6 flamingoGraphql "flamingo.me/graphql" 7 8 customerDomain "flamingo.me/flamingo-commerce/v3/customer/domain" 9 customerInfrastructure "flamingo.me/flamingo-commerce/v3/customer/infrastructure" 10 customerGraphql "flamingo.me/flamingo-commerce/v3/customer/interfaces/graphql" 11 ) 12 13 type ( 14 // Module registers our customer module 15 Module struct { 16 useNilCustomerAdapter bool 17 } 18 ) 19 20 // Inject module 21 func (m *Module) Inject(config *struct { 22 UseNilCustomerAdapter bool `inject:"config:commerce.customer.useNilCustomerAdapter,optional"` 23 }) { 24 if config != nil { 25 m.useNilCustomerAdapter = config.UseNilCustomerAdapter 26 } 27 } 28 29 // Configure module 30 func (m *Module) Configure(injector *dingo.Injector) { 31 if m.useNilCustomerAdapter { 32 injector.Bind((*customerDomain.CustomerIdentityService)(nil)).To(customerInfrastructure.NilCustomerServiceAdapter{}) 33 } 34 injector.BindMulti(new(flamingoGraphql.Service)).To(customerGraphql.Service{}) 35 } 36 37 // Depends on other modules 38 func (m *Module) Depends() []dingo.Module { 39 return []dingo.Module{ 40 new(auth.WebModule), 41 } 42 }