File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 6565New Features
6666============
6767
68+ Cache
69+ -----
70+
71+ - Added Redis Cluster support to ``RedisEngine ``. Configure the ``cluster `` option
72+ with an array of server addresses to enable cluster mode.
73+
6874Command
6975-------
7076
@@ -74,18 +80,18 @@ Command
7480- ``cake server `` now supports a ``--frankenphp `` option that will start the
7581 development server with `FrankenPHP <https://frankenphp.dev/ >`__.
7682
77- Cache
78- -----
79-
80- - Added Redis Cluster support to ``RedisEngine ``. Configure the ``cluster `` option
81- with an array of server addresses to enable cluster mode.
82-
8383Console
8484-------
8585
8686- Added ``TreeHelper `` which outputs an array as a tree such as an array of filesystem
8787 directories as array keys and files as lists under each directory.
8888
89+ Core
90+ ----
91+
92+ - Added ``Configure `` attribute to support injecting ``Configure `` values into
93+ constructor arguments. See ref:`configure-dependency-injection `.
94+
8995Database
9096--------
9197
Original file line number Diff line number Diff line change @@ -213,13 +213,28 @@ services like in a reporting system::
213213 return new ReportAggregate($container->get('reports'));
214214 });
215215
216+ .. _configure-dependency-injection :
217+
216218Using Configuration Data
217219------------------------
218220
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::
221+ Often you'll need configuration data in your services. If you need a specific value,
222+ you can inject it as a constructor argument using the ``Cake\Core\Attribute\Configure ``
223+ attribute::
224+
225+ use Cake\Core\Attribute\Configure;
226+
227+ class InjectedService
228+ {
229+ public function __construct(
230+ #[Configure('MyService.apiKey')] protected string $apiKey,
231+ ) { }
232+ }
233+
234+ .. versionadded :: 5.3.0
235+
236+ If you want to inject a copy of all configuration data, CakePHP includes
237+ an injectable configuration reader::
223238
224239 use Cake\Core\ServiceConfig;
225240
You can’t perform that action at this time.
0 commit comments