Skip to content

Commit bbd3a7a

Browse files
committed
Add migration notes for Configure attribute
1 parent ef6598c commit bbd3a7a

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

en/appendices/5-3-migration-guide.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
7790
Cache
7891
-----
7992

en/development/dependency-injection.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,23 @@ services like in a reporting system::
216216
Using 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

0 commit comments

Comments
 (0)