]> source.dussan.org Git - nextcloud-server.git/commit
feat(app framework)!: Inject services into controller methods 35783/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 15 Dec 2022 09:37:27 +0000 (10:37 +0100)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Wed, 18 Jan 2023 13:00:38 +0000 (14:00 +0100)
commit20fcfb573951a594f71afaf97678d38d8b05c9f2
tree9adb7ba2d021269dc0efd4d47d4076563a28c363
parent9e08e4999821a0cf7c6b08fd9ab05f8d057c8362
feat(app framework)!: Inject services into controller methods

Usually Nextcloud DI goes through constructor injection. This has the
implication that each instance of a class builds the full DI tree. That
is the injected services, their services, etc. Occasionally there is a
service that is only needed for one controller method. Then the DI tree
is build regardless if used or not.

If services are injected into the method, we only build the DI tree if
that method gets executed.

This is also how Laravel allows injection.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
core/Controller/LoginController.php
lib/private/AppFramework/DependencyInjection/DIContainer.php
lib/private/AppFramework/Http/Dispatcher.php
tests/Core/Controller/LoginControllerTest.php
tests/lib/AppFramework/Http/DispatcherTest.php