Refactor OC\Server::getAppManager#40113
Conversation
4fec546 to
642643a
Compare
Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
642643a to
522bc4d
Compare
| if (\OC::$server->getConfig()->getSystemValue('installed', false)) { | ||
| $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); | ||
| $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager())); | ||
| $application->add(new OC\Core\Command\App\Disable(\OC::$server->get(IAppManager::class))); |
There was a problem hiding this comment.
| $application->add(new OC\Core\Command\App\Disable(\OC::$server->get(IAppManager::class))); | |
| $application->add(\OCP\Server::get(\OC\Core\Command\App\Disable::class)); |
There was a problem hiding this comment.
Same for all others of course.
There was a problem hiding this comment.
I can add these changes to this PR if you would like, but should it be in its own PR? Either way works for me.
Shouldn't it be this (or something similar), though?
$application->add(\OCP\Server::get(\OC\Core\Command\App\Disable::class)(\OC::$server->get(IAppManager::class)));
There was a problem hiding this comment.
Well see this urgent comment before continuing the work: #40083 (comment)
Shouldn't it be this (or something similar), though?
The code you provided does not even parse in PHP. No, my suggested code basically removes all "manual injection of dependencies" and replaces it by "automatically injecting the actual command" which then on it's own will get all it's dependencies, instead of us listing hundreds of get() parameters here.
It might not work for all commands (some seem to get non-DI-able objects like new View() as a parameter), but should work for most of them.
| use OCP\App\IAppManager; | ||
| use Psr\Log\LoggerInterface; |
There was a problem hiding this comment.
| use OCP\App\IAppManager; | |
| use Psr\Log\LoggerInterface; | |
| use OCP\App\IAppManager; | |
| use Psr\Log\LoggerInterface; |
|
Too much conflicts, closing until this is done fresh again |
This PR refactors the deprecated method
OC\Server::getAppManagerand replaces it withOC\Server::get(\OCP\App\IAppManager::class)throughout the entire NC codebase (excluding./appsand./3rdparty).Additionally, where necessary, the
\OCP\App\IAppManagerclass is imported via theusedirective.