Skip to content

Commit d2c6018

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

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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

en/development/dependency-injection.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@ The ``ServiceConfig`` class provides a read-only view of all the data available
230230
in ``Configure`` so you don't have to worry about accidentally changing
231231
configuration.
232232

233+
Configure Property attribute
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+
233253
Service Providers
234254
=================
235255

0 commit comments

Comments
 (0)