-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -48,7 +48,9 @@ | |||||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||||||
* | ||||||
*/ | ||||||
use Psr\Log\LoggerInterface; | ||||||
|
||||||
use OCP\App\IAppManager; | ||||||
use Psr\Log\LoggerInterface; | ||||||
|
||||||
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand()); | ||||||
$application->add(new OC\Core\Command\Status(\OC::$server->get(\OCP\IConfig::class), \OC::$server->get(\OCP\Defaults::class))); | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well see this urgent comment before continuing the work: #40083 (comment)
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 It might not work for all commands (some seem to get non-DI-able objects like |
||||||
$application->add(new OC\Core\Command\App\Enable(\OC::$server->get(IAppManager::class), \OC::$server->getGroupManager())); | ||||||
summersab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
$application->add(new OC\Core\Command\App\Install()); | ||||||
$application->add(new OC\Core\Command\App\GetPath()); | ||||||
$application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); | ||||||
$application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->get(LoggerInterface::class))); | ||||||
$application->add(new OC\Core\Command\App\ListApps(\OC::$server->get(IAppManager::class))); | ||||||
$application->add(new OC\Core\Command\App\Remove(\OC::$server->get(IAppManager::class), \OC::$server->query(\OC\Installer::class), \OC::$server->get(LoggerInterface::class))); | ||||||
summersab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
$application->add(\OC::$server->query(\OC\Core\Command\App\Update::class)); | ||||||
|
||||||
$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class)); | ||||||
|
@@ -116,7 +118,7 @@ | |||||
if (\OC::$server->getConfig()->getSystemValueBool('debug', false)) { | ||||||
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->get(\OC\DB\Connection::class))); | ||||||
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->get(\OC\DB\Connection::class))); | ||||||
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getAppManager())); | ||||||
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->get(IAppManager::class))); | ||||||
$application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getConfig())); | ||||||
} | ||||||
|
||||||
|
@@ -125,10 +127,10 @@ | |||||
$application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); | ||||||
$application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); | ||||||
$application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager())); | ||||||
$application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); | ||||||
$application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->get(IAppManager::class), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); | ||||||
summersab marked this conversation as resolved.
Show resolved
Hide resolved
summersab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
$application->add(new OC\Core\Command\Encryption\DecryptAll( | ||||||
\OC::$server->getEncryptionManager(), | ||||||
\OC::$server->getAppManager(), | ||||||
\OC::$server->get(IAppManager::class), | ||||||
\OC::$server->getConfig(), | ||||||
new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()), | ||||||
new \Symfony\Component\Console\Helper\QuestionHelper()) | ||||||
|
@@ -174,7 +176,7 @@ | |||||
new \OC\Repair([], \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)), | ||||||
\OC::$server->getConfig(), | ||||||
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), | ||||||
\OC::$server->getAppManager() | ||||||
\OC::$server->get(IAppManager::class) | ||||||
)); | ||||||
$application->add(\OC::$server->query(OC\Core\Command\Maintenance\RepairShareOwnership::class)); | ||||||
|
||||||
|
@@ -188,7 +190,7 @@ | |||||
$application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager())); | ||||||
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager())); | ||||||
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class)); | ||||||
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager())); | ||||||
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->get(IAppManager::class))); | ||||||
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig())); | ||||||
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); | ||||||
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); | ||||||
|
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.