diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-05-10 01:12:22 +0300 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-05-10 01:12:22 +0300 |
commit | 4b23f5d53e8a39228580d262c2a7c8c2f9a8ad8d (patch) | |
tree | b55496f917f5d350b9e8b3724fcf340423a66926 | |
parent | fed2de15da989ffd782261004f0c2a0c8ad4fa16 (diff) |
Add section about OCP\Server::getupdate/dependency-injection
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r-- | developer_manual/basics/dependency_injection.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/developer_manual/basics/dependency_injection.rst b/developer_manual/basics/dependency_injection.rst index 653b7090e..d3efaf34f 100644 --- a/developer_manual/basics/dependency_injection.rst +++ b/developer_manual/basics/dependency_injection.rst @@ -393,3 +393,14 @@ What not to inject: * It is a `pure function <https://en.wikipedia.org/wiki/Pure_function>`_ .. _`reflection`: https://www.php.net/manual/en/book.reflection.php + + +Accessing the container from anywhere +------------------------------------ + +Sometimes it can be hard to inject some service inside legacy code, in these case +you can use :code:`OCP\Server::get(MyService::class)`. This should only be used in +the last resort, as this makes your code more complicated to unit test and is +considered an anti-pattern. + + |