File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,19 @@ Command
7474- ``cake server `` now supports a ``--frankenphp `` option that will start the
7575 development server with `FrankenPHP <https://frankenphp.dev/ >`__.
7676
77+ Core
78+ ----
79+
80+ - Added ``Configure `` attribute to support injecting ``Configure `` values into
81+ constructor arguments::
82+
83+ class InjectedService
84+ {
85+ public function __construct(
86+ #[Configure('MyService.apiKey')] protected string $apiKey,
87+ ) { }
88+ }
89+
7790Cache
7891-----
7992
Original file line number Diff line number Diff line change @@ -216,10 +216,23 @@ services like in a reporting system::
216216Using Configuration Data
217217------------------------
218218
219- Often you'll need configuration data in your services. While you could add
220- all the configuration keys your service needs into the container, that can be
221- tedious. To make configuration easier to work with CakePHP includes an
222- injectable configuration reader::
219+ Often you'll need configuration data in your services. If you need a specific value,
220+ you can inject it as a constructor argument using the ``Cake\Core\Attribute\Configure ``
221+ attribute::
222+
223+ use Cake\Core\Attribute\Configure;
224+
225+ class InjectedService
226+ {
227+ public function __construct(
228+ #[Configure('MyService.apiKey')] protected string $apiKey,
229+ ) { }
230+ }
231+
232+ .. versionadded :: 5.3.0
233+
234+ If you want to inject a copy of all configuration data, CakePHP includes
235+ an injectable configuration reader::
223236
224237 use Cake\Core\ServiceConfig;
225238
You can’t perform that action at this time.
0 commit comments