]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix PHP warnings when using occ with some LDAP commands
authorArthur Schiwon <blizzz@owncloud.com>
Mon, 23 Mar 2015 14:17:14 +0000 (15:17 +0100)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 23 Mar 2015 14:19:41 +0000 (15:19 +0100)
apps/user_ldap/appinfo/register_command.php
apps/user_ldap/command/createemptyconfig.php
apps/user_ldap/command/deleteconfig.php
apps/user_ldap/command/showconfig.php

index 651e6a564e1ccfb16811d63b7f6528dd4730cd7a..854f21aae35ebbeaae76f8f140fef61a9b15e5a4 100644 (file)
@@ -25,11 +25,11 @@ $deletedUsersIndex = new DeletedUsersIndex(
        $ocConfig, $dbConnection, $userMapping
 );
 
-$application->add(new OCA\user_ldap\Command\ShowConfig());
+$application->add(new OCA\user_ldap\Command\ShowConfig($helper));
 $application->add(new OCA\user_ldap\Command\SetConfig());
 $application->add(new OCA\user_ldap\Command\TestConfig());
-$application->add(new OCA\user_ldap\Command\CreateEmptyConfig());
-$application->add(new OCA\user_ldap\Command\DeleteConfig());
+$application->add(new OCA\user_ldap\Command\CreateEmptyConfig($helper));
+$application->add(new OCA\user_ldap\Command\DeleteConfig($helper));
 $application->add(new OCA\user_ldap\Command\Search($ocConfig));
 $application->add(new OCA\user_ldap\Command\ShowRemnants(
        $deletedUsersIndex, \OC::$server->getDateTimeFormatter())
index 3201082536135d7c33eb40b47eaf61d78e1a9bb8..1f051af9d5ab10eefbb368cac3b214aaf8380c95 100644 (file)
@@ -17,6 +17,16 @@ use \OCA\user_ldap\lib\Helper;
 use \OCA\user_ldap\lib\Configuration;
 
 class CreateEmptyConfig extends Command {
+       /** @var \OCA\User_LDAP\lib\Helper */
+       protected $helper;
+
+       /**
+        * @param Helper $helper
+        */
+       public function __construct(Helper $helper) {
+               $this->helper = $helper;
+               parent::__construct();
+       }
 
        protected function configure() {
                $this
@@ -25,7 +35,6 @@ class CreateEmptyConfig extends Command {
                ;
        }
 
-
        protected function execute(InputInterface $input, OutputInterface $output) {
                $configPrefix = $this->getNewConfigurationPrefix();
                $output->writeln("Created new configuration with configID '{$configPrefix}'");
@@ -35,7 +44,7 @@ class CreateEmptyConfig extends Command {
        }
 
        protected function getNewConfigurationPrefix() {
-               $serverConnections = Helper::getServerConfigurationPrefixes();
+               $serverConnections = $this->helper->getServerConfigurationPrefixes();
 
                // first connection uses no prefix
                if(sizeof($serverConnections) == 0) {
index f8b834a6465620be39deced47060a0745ecf8ccf..fcffc50f47ed92f91240d4cf06f16089d51e1624 100644 (file)
@@ -11,11 +11,20 @@ namespace OCA\user_ldap\Command;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 use \OCA\user_ldap\lib\Helper;
 
 class DeleteConfig extends Command {
+       /** @var \OCA\User_LDAP\lib\Helper */
+       protected $helper;
+
+       /**
+        * @param Helper $helper
+        */
+       public function __construct(Helper $helper) {
+               $this->helper = $helper;
+               parent::__construct();
+       }
 
        protected function configure() {
                $this
@@ -31,9 +40,9 @@ class DeleteConfig extends Command {
 
 
        protected function execute(InputInterface $input, OutputInterface $output) {
-               $configPrefix = $input->getArgument('configID');;
+               $configPrefix = $input->getArgument('configID');
 
-               $success = Helper::deleteServerConfiguration($configPrefix);
+               $success = $this->helper->deleteServerConfiguration($configPrefix);
 
                if($success) {
                        $output->writeln("Deleted configuration with configID '{$configPrefix}'");
index fbcf8d57de47fbfc2e7c440e8e7fd5e3f988ea5a..48ab76f1b7e828bbf31ceaa077f8dd532ce7cf81 100644 (file)
@@ -17,6 +17,16 @@ use \OCA\user_ldap\lib\Helper;
 use \OCA\user_ldap\lib\Configuration;
 
 class ShowConfig extends Command {
+       /** @var \OCA\User_LDAP\lib\Helper */
+       protected $helper;
+
+       /**
+        * @param Helper $helper
+        */
+       public function __construct(Helper $helper) {
+               $this->helper = $helper;
+               parent::__construct();
+       }
 
        protected function configure() {
                $this
@@ -37,8 +47,7 @@ class ShowConfig extends Command {
        }
 
        protected function execute(InputInterface $input, OutputInterface $output) {
-               $helper = new Helper();
-               $availableConfigs = $helper->getServerConfigurationPrefixes();
+               $availableConfigs = $this->helper->getServerConfigurationPrefixes();
                $configID = $input->getArgument('configID');
                if(!is_null($configID)) {
                        $configIDs[] = $configID;