From 52b284c971b1981e1d61a3c57b583551bcf430b7 Mon Sep 17 00:00:00 2001 From: Wenbo Han Date: Sun, 29 Sep 2024 23:01:31 +0800 Subject: [PATCH] fix: dependency error (#659) --- contracts/foundation/application.go | 85 +++++++++- contracts/foundation/container.go | 92 ---------- contracts/foundation/service_provider_test.go | 30 ---- foundation/application.go | 10 +- foundation/application_test.go | 60 +++---- foundation/container.go | 158 +++++++++--------- 6 files changed, 198 insertions(+), 237 deletions(-) delete mode 100644 contracts/foundation/container.go delete mode 100644 contracts/foundation/service_provider_test.go diff --git a/contracts/foundation/application.go b/contracts/foundation/application.go index 967a438b8..5694815c6 100644 --- a/contracts/foundation/application.go +++ b/contracts/foundation/application.go @@ -3,11 +3,32 @@ package foundation import ( "context" + "github.com/goravel/framework/contracts/auth" + "github.com/goravel/framework/contracts/auth/access" + "github.com/goravel/framework/contracts/cache" + "github.com/goravel/framework/contracts/config" "github.com/goravel/framework/contracts/console" + "github.com/goravel/framework/contracts/crypt" + "github.com/goravel/framework/contracts/database/migration" + "github.com/goravel/framework/contracts/database/orm" + "github.com/goravel/framework/contracts/database/seeder" + "github.com/goravel/framework/contracts/event" + "github.com/goravel/framework/contracts/filesystem" + "github.com/goravel/framework/contracts/grpc" + "github.com/goravel/framework/contracts/hash" + "github.com/goravel/framework/contracts/http" + "github.com/goravel/framework/contracts/log" + "github.com/goravel/framework/contracts/mail" + "github.com/goravel/framework/contracts/queue" + "github.com/goravel/framework/contracts/route" + "github.com/goravel/framework/contracts/schedule" + "github.com/goravel/framework/contracts/session" + "github.com/goravel/framework/contracts/testing" + "github.com/goravel/framework/contracts/translation" + "github.com/goravel/framework/contracts/validation" ) type Application interface { - Container // Boot register and bootstrap configured service providers. Boot() // Commands register the given commands with the console application. @@ -42,4 +63,66 @@ type Application interface { SetJson(json Json) // GetJson get the JSON implementation. GetJson() Json + + // Container + // Bind registers a binding with the container. + Bind(key any, callback func(app Application) (any, error)) + // BindWith registers a binding with the container. + BindWith(key any, callback func(app Application, parameters map[string]any) (any, error)) + // Instance registers an existing instance as shared in the container. + Instance(key, instance any) + // Make resolves the given type from the container. + Make(key any) (any, error) + // MakeArtisan resolves the artisan console instance. + MakeArtisan() console.Artisan + // MakeAuth resolves the auth instance. + MakeAuth(ctx http.Context) auth.Auth + // MakeCache resolves the cache instance. + MakeCache() cache.Cache + // MakeConfig resolves the config instance. + MakeConfig() config.Config + // MakeCrypt resolves the crypt instance. + MakeCrypt() crypt.Crypt + // MakeEvent resolves the event instance. + MakeEvent() event.Instance + // MakeGate resolves the gate instance. + MakeGate() access.Gate + // MakeGrpc resolves the grpc instance. + MakeGrpc() grpc.Grpc + // MakeHash resolves the hash instance. + MakeHash() hash.Hash + // MakeLang resolves the lang instance. + MakeLang(ctx context.Context) translation.Translator + // MakeLog resolves the log instance. + MakeLog() log.Log + // MakeMail resolves the mail instance. + MakeMail() mail.Mail + // MakeOrm resolves the orm instance. + MakeOrm() orm.Orm + // MakeQueue resolves the queue instance. + MakeQueue() queue.Queue + // MakeRateLimiter resolves the rate limiter instance. + MakeRateLimiter() http.RateLimiter + // MakeRoute resolves the route instance. + MakeRoute() route.Route + // MakeSchedule resolves the schedule instance. + MakeSchedule() schedule.Schedule + // MakeSchema resolves the schema instance. + MakeSchema() migration.Schema + // MakeSession resolves the session instance. + MakeSession() session.Manager + // MakeStorage resolves the storage instance. + MakeStorage() filesystem.Storage + // MakeTesting resolves the testing instance. + MakeTesting() testing.Testing + // MakeValidation resolves the validation instance. + MakeValidation() validation.Validation + // MakeView resolves the view instance. + MakeView() http.View + // MakeSeeder resolves the seeder instance. + MakeSeeder() seeder.Facade + // MakeWith resolves the given type with the given parameters from the container. + MakeWith(key any, parameters map[string]any) (any, error) + // Singleton registers a shared binding in the container. + Singleton(key any, callback func(app Application) (any, error)) } diff --git a/contracts/foundation/container.go b/contracts/foundation/container.go deleted file mode 100644 index 70253a5da..000000000 --- a/contracts/foundation/container.go +++ /dev/null @@ -1,92 +0,0 @@ -package foundation - -import ( - "context" - - "github.com/goravel/framework/contracts/auth" - "github.com/goravel/framework/contracts/auth/access" - "github.com/goravel/framework/contracts/cache" - "github.com/goravel/framework/contracts/config" - "github.com/goravel/framework/contracts/console" - "github.com/goravel/framework/contracts/crypt" - "github.com/goravel/framework/contracts/database/migration" - "github.com/goravel/framework/contracts/database/orm" - "github.com/goravel/framework/contracts/database/seeder" - "github.com/goravel/framework/contracts/event" - "github.com/goravel/framework/contracts/filesystem" - "github.com/goravel/framework/contracts/grpc" - "github.com/goravel/framework/contracts/hash" - "github.com/goravel/framework/contracts/http" - "github.com/goravel/framework/contracts/log" - "github.com/goravel/framework/contracts/mail" - "github.com/goravel/framework/contracts/queue" - "github.com/goravel/framework/contracts/route" - "github.com/goravel/framework/contracts/schedule" - "github.com/goravel/framework/contracts/session" - "github.com/goravel/framework/contracts/testing" - "github.com/goravel/framework/contracts/translation" - "github.com/goravel/framework/contracts/validation" -) - -type Container interface { - // Bind registers a binding with the container. - Bind(key any, callback func(app Application) (any, error)) - // BindWith registers a binding with the container. - BindWith(key any, callback func(app Application, parameters map[string]any) (any, error)) - // Instance registers an existing instance as shared in the container. - Instance(key, instance any) - // Make resolves the given type from the container. - Make(key any) (any, error) - // MakeArtisan resolves the artisan console instance. - MakeArtisan() console.Artisan - // MakeAuth resolves the auth instance. - MakeAuth(ctx http.Context) auth.Auth - // MakeCache resolves the cache instance. - MakeCache() cache.Cache - // MakeConfig resolves the config instance. - MakeConfig() config.Config - // MakeCrypt resolves the crypt instance. - MakeCrypt() crypt.Crypt - // MakeEvent resolves the event instance. - MakeEvent() event.Instance - // MakeGate resolves the gate instance. - MakeGate() access.Gate - // MakeGrpc resolves the grpc instance. - MakeGrpc() grpc.Grpc - // MakeHash resolves the hash instance. - MakeHash() hash.Hash - // MakeLang resolves the lang instance. - MakeLang(ctx context.Context) translation.Translator - // MakeLog resolves the log instance. - MakeLog() log.Log - // MakeMail resolves the mail instance. - MakeMail() mail.Mail - // MakeOrm resolves the orm instance. - MakeOrm() orm.Orm - // MakeQueue resolves the queue instance. - MakeQueue() queue.Queue - // MakeRateLimiter resolves the rate limiter instance. - MakeRateLimiter() http.RateLimiter - // MakeRoute resolves the route instance. - MakeRoute() route.Route - // MakeSchedule resolves the schedule instance. - MakeSchedule() schedule.Schedule - // MakeSchema resolves the schema instance. - MakeSchema() migration.Schema - // MakeSession resolves the session instance. - MakeSession() session.Manager - // MakeStorage resolves the storage instance. - MakeStorage() filesystem.Storage - // MakeTesting resolves the testing instance. - MakeTesting() testing.Testing - // MakeValidation resolves the validation instance. - MakeValidation() validation.Validation - // MakeView resolves the view instance. - MakeView() http.View - // MakeSeeder resolves the seeder instance. - MakeSeeder() seeder.Facade - // MakeWith resolves the given type with the given parameters from the container. - MakeWith(key any, parameters map[string]any) (any, error) - // Singleton registers a shared binding in the container. - Singleton(key any, callback func(app Application) (any, error)) -} diff --git a/contracts/foundation/service_provider_test.go b/contracts/foundation/service_provider_test.go deleted file mode 100644 index 02bc97ed1..000000000 --- a/contracts/foundation/service_provider_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package foundation - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -var testRegister = 0 - -type testServiceProvider struct { - *BaseServiceProvider -} - -func (t *testServiceProvider) Register(Application) { - testRegister++ -} - -func TestBaseServiceProvider(t *testing.T) { - var sp = &testServiceProvider{} - - _, ok := interface{}(sp).(ServiceProvider) - - assert.True(t, ok) - - sp.Register(nil) - sp.Boot(nil) - - assert.Equal(t, 1, testRegister) -} diff --git a/foundation/application.go b/foundation/application.go index f526b32aa..0cc8b7b76 100644 --- a/foundation/application.go +++ b/foundation/application.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/goravel/framework/config" - consolecontract "github.com/goravel/framework/contracts/console" + contractsconsole "github.com/goravel/framework/contracts/console" "github.com/goravel/framework/contracts/foundation" "github.com/goravel/framework/foundation/console" "github.com/goravel/framework/foundation/json" @@ -38,7 +38,7 @@ func init() { } type Application struct { - foundation.Container + *Container publishes map[string]map[string]string publishGroups map[string]map[string]string json foundation.Json @@ -52,7 +52,7 @@ func NewApplication() foundation.Application { func (app *Application) Boot() { app.registerConfiguredServiceProviders() app.bootConfiguredServiceProviders() - app.registerCommands([]consolecontract.Command{ + app.registerCommands([]contractsconsole.Command{ console.NewTestMakeCommand(), console.NewPackageMakeCommand(), console.NewVendorPublishCommand(app.publishes, app.publishGroups), @@ -61,7 +61,7 @@ func (app *Application) Boot() { app.bootArtisan() } -func (app *Application) Commands(commands []consolecontract.Command) { +func (app *Application) Commands(commands []contractsconsole.Command) { app.registerCommands(commands) } @@ -209,7 +209,7 @@ func (app *Application) bootServiceProviders(serviceProviders []foundation.Servi } } -func (app *Application) registerCommands(commands []consolecontract.Command) { +func (app *Application) registerCommands(commands []contractsconsole.Command) { app.MakeArtisan().Register(commands) } diff --git a/foundation/application_test.go b/foundation/application_test.go index c563e9307..58e37c1b5 100644 --- a/foundation/application_test.go +++ b/foundation/application_test.go @@ -23,13 +23,13 @@ import ( "github.com/goravel/framework/http" frameworklog "github.com/goravel/framework/log" "github.com/goravel/framework/mail" - cachemocks "github.com/goravel/framework/mocks/cache" - configmocks "github.com/goravel/framework/mocks/config" - consolemocks "github.com/goravel/framework/mocks/console" - ormmocks "github.com/goravel/framework/mocks/database/orm" - logmocks "github.com/goravel/framework/mocks/log" - queuemocks "github.com/goravel/framework/mocks/queue" - routemocks "github.com/goravel/framework/mocks/route" + mockscache "github.com/goravel/framework/mocks/cache" + mocksconfig "github.com/goravel/framework/mocks/config" + mocksconsole "github.com/goravel/framework/mocks/console" + mocksorm "github.com/goravel/framework/mocks/database/orm" + mockslog "github.com/goravel/framework/mocks/log" + mocksqueue "github.com/goravel/framework/mocks/queue" + mocksroute "github.com/goravel/framework/mocks/route" "github.com/goravel/framework/queue" "github.com/goravel/framework/schedule" frameworksession "github.com/goravel/framework/session" @@ -83,7 +83,7 @@ func (s *ApplicationTestSuite) TestStoragePath() { } func (s *ApplicationTestSuite) TestLangPath() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.EXPECT().GetString("app.lang_path", "lang").Return("test").Once() s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { @@ -149,17 +149,17 @@ func (s *ApplicationTestSuite) TestMakeArtisan() { } func (s *ApplicationTestSuite) TestMakeAuth() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "auth.defaults.guard").Return("user").Once() s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { return mockConfig, nil }) s.app.Singleton(cache.Binding, func(app foundation.Application) (any, error) { - return &cachemocks.Cache{}, nil + return &mockscache.Cache{}, nil }) s.app.Singleton(database.BindingOrm, func(app foundation.Application) (any, error) { - return &ormmocks.Orm{}, nil + return &mocksorm.Orm{}, nil }) serviceProvider := &auth.ServiceProvider{} @@ -170,7 +170,7 @@ func (s *ApplicationTestSuite) TestMakeAuth() { } func (s *ApplicationTestSuite) TestMakeCache() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "cache.default").Return("memory").Once() mockConfig.On("GetString", "cache.stores.memory.driver").Return("memory").Once() mockConfig.On("GetString", "cache.prefix").Return("goravel").Once() @@ -179,7 +179,7 @@ func (s *ApplicationTestSuite) TestMakeCache() { return mockConfig, nil }) s.app.Singleton(frameworklog.Binding, func(app foundation.Application) (any, error) { - return &logmocks.Log{}, nil + return &mockslog.Log{}, nil }) serviceProvider := &cache.ServiceProvider{} @@ -197,7 +197,7 @@ func (s *ApplicationTestSuite) TestMakeConfig() { } func (s *ApplicationTestSuite) TestMakeCrypt() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "app.key").Return("12345678901234567890123456789012").Once() s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { @@ -213,7 +213,7 @@ func (s *ApplicationTestSuite) TestMakeCrypt() { func (s *ApplicationTestSuite) TestMakeEvent() { s.app.Singleton(queue.Binding, func(app foundation.Application) (any, error) { - return &queuemocks.Queue{}, nil + return &mocksqueue.Queue{}, nil }) serviceProvider := &event.ServiceProvider{} @@ -231,7 +231,7 @@ func (s *ApplicationTestSuite) TestMakeGate() { func (s *ApplicationTestSuite) TestMakeGrpc() { s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { - return &configmocks.Config{}, nil + return &mocksconfig.Config{}, nil }) serviceProvider := &grpc.ServiceProvider{} @@ -241,7 +241,7 @@ func (s *ApplicationTestSuite) TestMakeGrpc() { } func (s *ApplicationTestSuite) TestMakeHash() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "hashing.driver", "argon2id").Return("argon2id").Once() mockConfig.On("GetInt", "hashing.argon2id.time", 4).Return(4).Once() mockConfig.On("GetInt", "hashing.argon2id.memory", 65536).Return(65536).Once() @@ -259,7 +259,7 @@ func (s *ApplicationTestSuite) TestMakeHash() { } func (s *ApplicationTestSuite) TestMakeLang() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "app.locale").Return("en").Once() mockConfig.On("GetString", "app.fallback_locale").Return("en").Once() mockConfig.On("GetString", "app.lang_path", "lang").Return("lang").Once() @@ -268,7 +268,7 @@ func (s *ApplicationTestSuite) TestMakeLang() { return mockConfig, nil }) s.app.Singleton(frameworklog.Binding, func(app foundation.Application) (any, error) { - return &logmocks.Log{}, nil + return &mockslog.Log{}, nil }) serviceProvider := &frameworktranslation.ServiceProvider{} @@ -288,10 +288,10 @@ func (s *ApplicationTestSuite) TestMakeLog() { func (s *ApplicationTestSuite) TestMakeMail() { s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { - return &configmocks.Config{}, nil + return &mocksconfig.Config{}, nil }) s.app.Singleton(queue.Binding, func(app foundation.Application) (any, error) { - return &queuemocks.Queue{}, nil + return &mocksqueue.Queue{}, nil }) serviceProvider := &mail.ServiceProvider{} @@ -307,7 +307,7 @@ func (s *ApplicationTestSuite) TestMakeOrm() { mysqlDocker := supportdocker.Mysql() config := mysqlDocker.Config() - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "database.default").Return("mysql").Once() mockConfig.On("Get", "database.connections.mysql.read").Return(nil).Once() mockConfig.On("Get", "database.connections.mysql.write").Return(nil).Once() @@ -340,7 +340,7 @@ func (s *ApplicationTestSuite) TestMakeOrm() { func (s *ApplicationTestSuite) TestMakeQueue() { s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { - return &configmocks.Config{}, nil + return &mocksconfig.Config{}, nil }) serviceProvider := &queue.ServiceProvider{} @@ -357,13 +357,13 @@ func (s *ApplicationTestSuite) TestMakeRateLimiter() { } func (s *ApplicationTestSuite) TestMakeRoute() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { return mockConfig, nil }) - mockRoute := &routemocks.Route{} + mockRoute := &mocksroute.Route{} s.app.Singleton("goravel.route", func(app foundation.Application) (any, error) { return mockRoute, nil }) @@ -373,17 +373,17 @@ func (s *ApplicationTestSuite) TestMakeRoute() { } func (s *ApplicationTestSuite) TestMakeSchedule() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetBool", "app.debug").Return(false).Once() s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) { return mockConfig, nil }) s.app.Singleton(console.Binding, func(app foundation.Application) (any, error) { - return &consolemocks.Artisan{}, nil + return &mocksconsole.Artisan{}, nil }) s.app.Singleton(frameworklog.Binding, func(app foundation.Application) (any, error) { - return &logmocks.Log{}, nil + return &mockslog.Log{}, nil }) serviceProvider := &schedule.ServiceProvider{} @@ -394,7 +394,7 @@ func (s *ApplicationTestSuite) TestMakeSchedule() { } func (s *ApplicationTestSuite) TestMakeSession() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetInt", "session.lifetime").Return(120).Once() mockConfig.On("GetInt", "session.gc_interval", 30).Return(30).Once() mockConfig.On("GetString", "session.files").Return("storage/framework/sessions").Once() @@ -414,7 +414,7 @@ func (s *ApplicationTestSuite) TestMakeSession() { } func (s *ApplicationTestSuite) TestMakeStorage() { - mockConfig := &configmocks.Config{} + mockConfig := &mocksconfig.Config{} mockConfig.On("GetString", "filesystems.default").Return("local").Once() mockConfig.On("GetString", "filesystems.disks.local.driver").Return("local").Once() mockConfig.On("GetString", "filesystems.disks.local.root").Return("").Once() diff --git a/foundation/container.go b/foundation/container.go index d6a76debb..8f589314e 100644 --- a/foundation/container.go +++ b/foundation/container.go @@ -9,30 +9,30 @@ import ( "github.com/goravel/framework/cache" "github.com/goravel/framework/config" "github.com/goravel/framework/console" - authcontract "github.com/goravel/framework/contracts/auth" - accesscontract "github.com/goravel/framework/contracts/auth/access" - cachecontract "github.com/goravel/framework/contracts/cache" - configcontract "github.com/goravel/framework/contracts/config" - consolecontract "github.com/goravel/framework/contracts/console" - cryptcontract "github.com/goravel/framework/contracts/crypt" - migrationcontract "github.com/goravel/framework/contracts/database/migration" - ormcontract "github.com/goravel/framework/contracts/database/orm" - seerdercontract "github.com/goravel/framework/contracts/database/seeder" - eventcontract "github.com/goravel/framework/contracts/event" - filesystemcontract "github.com/goravel/framework/contracts/filesystem" - foundationcontract "github.com/goravel/framework/contracts/foundation" - grpccontract "github.com/goravel/framework/contracts/grpc" - hashcontract "github.com/goravel/framework/contracts/hash" - httpcontract "github.com/goravel/framework/contracts/http" - logcontract "github.com/goravel/framework/contracts/log" - mailcontract "github.com/goravel/framework/contracts/mail" - queuecontract "github.com/goravel/framework/contracts/queue" - routecontract "github.com/goravel/framework/contracts/route" - schedulecontract "github.com/goravel/framework/contracts/schedule" - sessioncontract "github.com/goravel/framework/contracts/session" - testingcontract "github.com/goravel/framework/contracts/testing" - translationcontract "github.com/goravel/framework/contracts/translation" - validationcontract "github.com/goravel/framework/contracts/validation" + contractsauth "github.com/goravel/framework/contracts/auth" + contractsaccess "github.com/goravel/framework/contracts/auth/access" + contractscache "github.com/goravel/framework/contracts/cache" + contractsconfig "github.com/goravel/framework/contracts/config" + contractsconsole "github.com/goravel/framework/contracts/console" + contractscrypt "github.com/goravel/framework/contracts/crypt" + contractsmigration "github.com/goravel/framework/contracts/database/migration" + contractsorm "github.com/goravel/framework/contracts/database/orm" + contractsseerder "github.com/goravel/framework/contracts/database/seeder" + contractsevent "github.com/goravel/framework/contracts/event" + contractsfilesystem "github.com/goravel/framework/contracts/filesystem" + contractsfoundation "github.com/goravel/framework/contracts/foundation" + contractsgrpc "github.com/goravel/framework/contracts/grpc" + contractshash "github.com/goravel/framework/contracts/hash" + contractshttp "github.com/goravel/framework/contracts/http" + contractslog "github.com/goravel/framework/contracts/log" + contractsmail "github.com/goravel/framework/contracts/mail" + contractsqueue "github.com/goravel/framework/contracts/queue" + contractsroute "github.com/goravel/framework/contracts/route" + contractsschedule "github.com/goravel/framework/contracts/schedule" + contractsession "github.com/goravel/framework/contracts/session" + contractstesting "github.com/goravel/framework/contracts/testing" + contractstranslation "github.com/goravel/framework/contracts/translation" + contractsvalidation "github.com/goravel/framework/contracts/validation" "github.com/goravel/framework/crypt" "github.com/goravel/framework/database" "github.com/goravel/framework/event" @@ -40,7 +40,7 @@ import ( "github.com/goravel/framework/grpc" "github.com/goravel/framework/hash" "github.com/goravel/framework/http" - goravellog "github.com/goravel/framework/log" + frameworklog "github.com/goravel/framework/log" "github.com/goravel/framework/mail" "github.com/goravel/framework/queue" "github.com/goravel/framework/route" @@ -66,11 +66,11 @@ func NewContainer() *Container { return &Container{} } -func (c *Container) Bind(key any, callback func(app foundationcontract.Application) (any, error)) { +func (c *Container) Bind(key any, callback func(app contractsfoundation.Application) (any, error)) { c.bindings.Store(key, instance{concrete: callback, shared: false}) } -func (c *Container) BindWith(key any, callback func(app foundationcontract.Application, parameters map[string]any) (any, error)) { +func (c *Container) BindWith(key any, callback func(app contractsfoundation.Application, parameters map[string]any) (any, error)) { c.bindings.Store(key, instance{concrete: callback, shared: false}) } @@ -82,17 +82,17 @@ func (c *Container) Make(key any) (any, error) { return c.make(key, nil) } -func (c *Container) MakeArtisan() consolecontract.Artisan { +func (c *Container) MakeArtisan() contractsconsole.Artisan { instance, err := c.Make(console.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(consolecontract.Artisan) + return instance.(contractsconsole.Artisan) } -func (c *Container) MakeAuth(ctx httpcontract.Context) authcontract.Auth { +func (c *Container) MakeAuth(ctx contractshttp.Context) contractsauth.Auth { instance, err := c.MakeWith(auth.BindingAuth, map[string]any{ "ctx": ctx, }) @@ -101,80 +101,80 @@ func (c *Container) MakeAuth(ctx httpcontract.Context) authcontract.Auth { return nil } - return instance.(authcontract.Auth) + return instance.(contractsauth.Auth) } -func (c *Container) MakeCache() cachecontract.Cache { +func (c *Container) MakeCache() contractscache.Cache { instance, err := c.Make(cache.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(cachecontract.Cache) + return instance.(contractscache.Cache) } -func (c *Container) MakeConfig() configcontract.Config { +func (c *Container) MakeConfig() contractsconfig.Config { instance, err := c.Make(config.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(configcontract.Config) + return instance.(contractsconfig.Config) } -func (c *Container) MakeCrypt() cryptcontract.Crypt { +func (c *Container) MakeCrypt() contractscrypt.Crypt { instance, err := c.Make(crypt.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(cryptcontract.Crypt) + return instance.(contractscrypt.Crypt) } -func (c *Container) MakeEvent() eventcontract.Instance { +func (c *Container) MakeEvent() contractsevent.Instance { instance, err := c.Make(event.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(eventcontract.Instance) + return instance.(contractsevent.Instance) } -func (c *Container) MakeGate() accesscontract.Gate { +func (c *Container) MakeGate() contractsaccess.Gate { instance, err := c.Make(auth.BindingGate) if err != nil { color.Red().Println(err) return nil } - return instance.(accesscontract.Gate) + return instance.(contractsaccess.Gate) } -func (c *Container) MakeGrpc() grpccontract.Grpc { +func (c *Container) MakeGrpc() contractsgrpc.Grpc { instance, err := c.Make(grpc.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(grpccontract.Grpc) + return instance.(contractsgrpc.Grpc) } -func (c *Container) MakeHash() hashcontract.Hash { +func (c *Container) MakeHash() contractshash.Hash { instance, err := c.Make(hash.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(hashcontract.Hash) + return instance.(contractshash.Hash) } -func (c *Container) MakeLang(ctx context.Context) translationcontract.Translator { +func (c *Container) MakeLang(ctx context.Context) contractstranslation.Translator { instance, err := c.MakeWith(translation.Binding, map[string]any{ "ctx": ctx, }) @@ -183,140 +183,140 @@ func (c *Container) MakeLang(ctx context.Context) translationcontract.Translator return nil } - return instance.(translationcontract.Translator) + return instance.(contractstranslation.Translator) } -func (c *Container) MakeLog() logcontract.Log { - instance, err := c.Make(goravellog.Binding) +func (c *Container) MakeLog() contractslog.Log { + instance, err := c.Make(frameworklog.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(logcontract.Log) + return instance.(contractslog.Log) } -func (c *Container) MakeMail() mailcontract.Mail { +func (c *Container) MakeMail() contractsmail.Mail { instance, err := c.Make(mail.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(mailcontract.Mail) + return instance.(contractsmail.Mail) } -func (c *Container) MakeOrm() ormcontract.Orm { +func (c *Container) MakeOrm() contractsorm.Orm { instance, err := c.Make(database.BindingOrm) if err != nil { color.Red().Println(err) return nil } - return instance.(ormcontract.Orm) + return instance.(contractsorm.Orm) } -func (c *Container) MakeQueue() queuecontract.Queue { +func (c *Container) MakeQueue() contractsqueue.Queue { instance, err := c.Make(queue.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(queuecontract.Queue) + return instance.(contractsqueue.Queue) } -func (c *Container) MakeRateLimiter() httpcontract.RateLimiter { +func (c *Container) MakeRateLimiter() contractshttp.RateLimiter { instance, err := c.Make(http.BindingRateLimiter) if err != nil { color.Red().Println(err) return nil } - return instance.(httpcontract.RateLimiter) + return instance.(contractshttp.RateLimiter) } -func (c *Container) MakeRoute() routecontract.Route { +func (c *Container) MakeRoute() contractsroute.Route { instance, err := c.Make(route.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(routecontract.Route) + return instance.(contractsroute.Route) } -func (c *Container) MakeSchedule() schedulecontract.Schedule { +func (c *Container) MakeSchedule() contractsschedule.Schedule { instance, err := c.Make(schedule.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(schedulecontract.Schedule) + return instance.(contractsschedule.Schedule) } -func (c *Container) MakeSchema() migrationcontract.Schema { +func (c *Container) MakeSchema() contractsmigration.Schema { instance, err := c.Make(database.BindingSchema) if err != nil { color.Red().Println(err) return nil } - return instance.(migrationcontract.Schema) + return instance.(contractsmigration.Schema) } -func (c *Container) MakeSession() sessioncontract.Manager { +func (c *Container) MakeSession() contractsession.Manager { instance, err := c.Make(session.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(sessioncontract.Manager) + return instance.(contractsession.Manager) } -func (c *Container) MakeStorage() filesystemcontract.Storage { +func (c *Container) MakeStorage() contractsfilesystem.Storage { instance, err := c.Make(filesystem.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(filesystemcontract.Storage) + return instance.(contractsfilesystem.Storage) } -func (c *Container) MakeTesting() testingcontract.Testing { +func (c *Container) MakeTesting() contractstesting.Testing { instance, err := c.Make(testing.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(testingcontract.Testing) + return instance.(contractstesting.Testing) } -func (c *Container) MakeValidation() validationcontract.Validation { +func (c *Container) MakeValidation() contractsvalidation.Validation { instance, err := c.Make(validation.Binding) if err != nil { color.Red().Println(err) return nil } - return instance.(validationcontract.Validation) + return instance.(contractsvalidation.Validation) } -func (c *Container) MakeView() httpcontract.View { +func (c *Container) MakeView() contractshttp.View { instance, err := c.Make(http.BindingView) if err != nil { color.Red().Println(err) return nil } - return instance.(httpcontract.View) + return instance.(contractshttp.View) } -func (c *Container) MakeSeeder() seerdercontract.Facade { +func (c *Container) MakeSeeder() contractsseerder.Facade { instance, err := c.Make(database.BindingSeeder) if err != nil { @@ -324,14 +324,14 @@ func (c *Container) MakeSeeder() seerdercontract.Facade { return nil } - return instance.(seerdercontract.Facade) + return instance.(contractsseerder.Facade) } func (c *Container) MakeWith(key any, parameters map[string]any) (any, error) { return c.make(key, parameters) } -func (c *Container) Singleton(key any, callback func(app foundationcontract.Application) (any, error)) { +func (c *Container) Singleton(key any, callback func(app contractsfoundation.Application) (any, error)) { c.bindings.Store(key, instance{concrete: callback, shared: true}) } @@ -350,7 +350,7 @@ func (c *Container) make(key any, parameters map[string]any) (any, error) { bindingImpl := binding.(instance) switch concrete := bindingImpl.concrete.(type) { - case func(app foundationcontract.Application) (any, error): + case func(app contractsfoundation.Application) (any, error): concreteImpl, err := concrete(App) if err != nil { return nil, err @@ -360,7 +360,7 @@ func (c *Container) make(key any, parameters map[string]any) (any, error) { } return concreteImpl, nil - case func(app foundationcontract.Application, parameters map[string]any) (any, error): + case func(app contractsfoundation.Application, parameters map[string]any) (any, error): concreteImpl, err := concrete(App, parameters) if err != nil { return nil, err