-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor OC\Server::getAppManager
#40113
Refactor OC\Server::getAppManager
#40113
Conversation
4fec546
to
642643a
Compare
Signed-off-by: Andrew Summers <[email protected]>
642643a
to
522bc4d
Compare
@@ -72,12 +74,12 @@ | |||
|
|||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for all others of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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::getAppManager
and replaces it withOC\Server::get(\OCP\App\IAppManager::class)
throughout the entire NC codebase (excluding./apps
and./3rdparty
).Additionally, where necessary, the
\OCP\App\IAppManager
class is imported via theuse
directive.