-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcontainer.go
38 lines (33 loc) · 939 Bytes
/
container.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Package container includes the Container type, witch contains a collection of modules.
*/
package container
import (
"github.com/DoNewsCode/core/contract"
)
var _ contract.Container = (*Container)(nil)
// Container holds all modules registered.
type Container struct {
modules []any
}
// Modules returns all modules in the container. This method is used to scan for
// custom interfaces. For example, The database module use Modules to scan for
// database migrations.
/*
m.container.Modules().Filter(func(p MigrationProvider) {
for _, migration := range p.ProvideMigration() {
if migration.Connection == "" {
migration.Connection = "default"
}
if migration.Connection == connection {
migrations.Collection = append(migrations.Collection, migration)
}
}
})
*/
func (c *Container) Modules() []any {
return c.modules
}
func (c *Container) AddModule(module any) {
c.modules = append(c.modules, module)
}