Skip to content

Commit f43f031

Browse files
authored
Merge pull request #8118 from cakephp/table-container
Add documentation for cakephp/cakephp#18979
2 parents 6217fee + 7896e4b commit f43f031

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ ORM
148148
validation to the fields listed in the ``fields`` option.
149149
- Added ``TableContainer`` that you can register in your Application::services() to
150150
add dependency injection for your Tables.
151+
- ``Cake\ORM\Locator\TableContainer`` was added. By adding this container
152+
delegate to your application, ORM Tables can be injected by the DI container.
151153

152154
Routing
153155
-------

en/development/dependency-injection.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ instance, often referred to as a singleton, you can mark a service as 'shared'::
188188

189189
$container->addShared(BillingService::class);
190190

191+
Using ORM Tables as Services
192+
----------------------------
193+
194+
If you want to have ORM Tables injected as a dependency to a service, you can
195+
add ``TableContainer`` to your applications's service container::
196+
197+
// In your Application::services() method.
198+
// Allow your Tables to be dependency injected.
199+
$container->delegate(new \Cake\ORM\Locator\TableContainer());
200+
201+
.. versionadded:: 5.3.0
202+
``TableContainer`` was added.
203+
191204
Extending Definitions
192205
---------------------
193206

0 commit comments

Comments
 (0)