flamingo.me/flamingo-commerce/v3@v3.11.0/w3cdatalayer/interfaces/templatefunctions/w3cDatalayerService.go (about)

     1  package templatefunctions
     2  
     3  import (
     4  	"context"
     5  
     6  	"flamingo.me/flamingo-commerce/v3/w3cdatalayer/application"
     7  )
     8  
     9  type (
    10  	// W3cDatalayerService struct for the template function
    11  	W3cDatalayerService struct {
    12  		applicationServiceProvider application.ServiceProvider
    13  	}
    14  )
    15  
    16  // Inject dependencies
    17  func (w3cdl *W3cDatalayerService) Inject(provider application.ServiceProvider) {
    18  	w3cdl.applicationServiceProvider = provider
    19  }
    20  
    21  // Func template function factory
    22  func (w3cdl *W3cDatalayerService) Func(ctx context.Context) interface{} {
    23  	// Usage
    24  	// w3cDatalayerService().get()
    25  	return func() *application.Service {
    26  		service := w3cdl.applicationServiceProvider()
    27  		service.Init(ctx)
    28  		return service
    29  	}
    30  }