1010use OCA \User_LDAP \Configuration ;
1111use OCA \User_LDAP \ConnectionFactory ;
1212use OCA \User_LDAP \Helper ;
13- use OCA \User_LDAP \LDAP ;
14- use OCP \Server ;
1513use Symfony \Component \Console \Command \Command ;
1614use Symfony \Component \Console \Input \InputArgument ;
1715use Symfony \Component \Console \Input \InputInterface ;
1816use Symfony \Component \Console \Output \OutputInterface ;
1917
2018class SetConfig extends Command {
19+ public function __construct (
20+ private readonly Helper $ helper ,
21+ private readonly ConnectionFactory $ connectionFactory ,
22+ ) {
23+ parent ::__construct ();
24+ }
25+
2126 protected function configure (): void {
2227 $ this
2328 ->setName ('ldap:set-config ' )
@@ -41,8 +46,7 @@ protected function configure(): void {
4146 }
4247
4348 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
44- $ helper = Server::get (Helper::class);
45- $ availableConfigs = $ helper ->getServerConfigurationPrefixes ();
49+ $ availableConfigs = $ this ->helper ->getServerConfigurationPrefixes ();
4650 $ configID = $ input ->getArgument ('configID ' );
4751 if (!in_array ($ configID , $ availableConfigs )) {
4852 $ output ->writeln ('Invalid configID ' );
@@ -65,7 +69,6 @@ protected function setValue(string $configID, string $key, string $value): void
6569 $ configHolder ->$ key = $ value ;
6670 $ configHolder ->saveConfiguration ();
6771
68- $ connectionFactory = new ConnectionFactory (new LDAP ());
69- $ connectionFactory ->get ($ configID )->clearCache ();
72+ $ this ->connectionFactory ->get ($ configID )->clearCache ();
7073 }
7174}
0 commit comments