就是 false。autowire:false 意味着如果服务的构造方法中需要参数,则必须手动的在
79 # arguments 字段中明确的设置。
80 # 也就是说所谓的 autowire 就是自动注入构造方法中所需要的参数而无须手动声明。
81 App\Services\TestAutowire\TestAutowire:
82 class: App\Services\TestAutowire\TestAutowire
83 public: true
84 arguments:
85 - '@App\Services\TestAutowire\TestAutowireArg'
86 App\Services\TestAutowire\TestAutowireArg:
87 class: App\Services\TestAutowire\TestAutowireArg
88
89 # 设置了 autowire:true 则无需手动设置构造方法的参数了
90 # App\Services\TestAutowire\TestAutowire:
91 # class: App\Services\TestAutowire\TestAutowire
92 # public: true
93 # autowire: true
94 # App\Services\TestAutowire\TestAutowireArg:
95 # class: App\Services\TestAutowire\TestAutowireArg
96
97 ############################## 父服务与子服务 ############################################################
98 App\Services\ParentAndChild\ParentService:
99 class: App\Services\ParentAndChild\ParentService
100 public: true
101 abstract: true
102 arguments:
103 $someService1: '@App\Services\ParentAndChild\SomeService1'
104 $someService2: '@App\Services\ParentAndChild\SomeService2'
105 App\Services\ParentAndChild\ChildService:
106 class: App\Services\ParentAndChild\ChildService
107 parent: App\Services\ParentAndChild\ParentService
108 public: true
109 # 波浪线表示 null,容器会使用默认的设置,不能通过 get() 获取,因为默认 public:false
110 App\Services\ParentAndChild\SomeService1: ~
111 App\Services\ParentAndChild\SomeService2: ~
|