File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,21 @@ 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 promoted properties when resolving a class from container. Example:
82+
83+ .. code-block :: php
84+
85+ class InjectedService
86+ {
87+ public function __construct(
88+ #[Configure('MyService.apiKey')] protected string $apiKey,
89+ ) { }
90+ }
91+
7792 Cache
7893-----
7994
Original file line number Diff line number Diff line change @@ -230,6 +230,26 @@ The ``ServiceConfig`` class provides a read-only view of all the data available
230230in ``Configure `` so you don't have to worry about accidentally changing
231231configuration.
232232
233+ Injecting Configure Values
234+ ----------------------------
235+
236+ Configure values can also be injected into constructor promoted properties using
237+ the ``Cake\Core\Attribute\Configure `` attribute. This attribute takes the ``Configure ``
238+ key as a parameter and the property will be set to that value when resolved.
239+
240+ .. code-block :: php
241+
242+ use Cake\Core\Attribute\Configure;
243+
244+ class InjectedService
245+ {
246+ public function __construct(
247+ #[Configure('MyService.apiKey')] protected string $apiKey,
248+ ) { }
249+ }
250+
251+ .. versionadded :: 5.3.0
252+
233253Service Providers
234254=================
235255
You can’t perform that action at this time.
0 commit comments