File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 76
76
a typesafe way to cast request data or other input and return ``null `` when conversion fails.
77
77
- ``pathCombine() `` was added to help build paths without worrying about duplicate and trailing slashes.
78
78
79
+ Controller
80
+ ----------
81
+
82
+ - Components can now use the DI container to have dependencies resolved and
83
+ provided as constructor parameters just like Controllers and Commands do.
84
+
79
85
Database
80
86
--------
81
87
Original file line number Diff line number Diff line change @@ -183,6 +183,29 @@ component would look something like this::
183
183
All components must extend :php:class: `Cake\\ Controller\\ Component `. Failing
184
184
to do this will trigger an exception.
185
185
186
+ Components can use :doc: `/development/dependency-injection ` to receive services
187
+ as constructor parameters::
188
+
189
+ namespace App\Controller\Component;
190
+
191
+ use Cake\Controller\Component;
192
+ use App\Service\UserService;
193
+
194
+ class SsoComponent extends Component
195
+ {
196
+ public function __construct(
197
+ ComponentRegistry $registry,
198
+ array $config = [],
199
+ UserService $users
200
+ ) {
201
+ parent::__construct($registry, $config);
202
+ $this->users = $users;
203
+ }
204
+ }
205
+
206
+ .. versionadded: 5.1.0
207
+ DI container support for Components was added.
208
+
186
209
Including your Component in your Controllers
187
210
--------------------------------------------
188
211
You can’t perform that action at this time.
0 commit comments