fix PHP warnings when using occ with some LDAP commands

This commit is contained in:
Arthur Schiwon 2015-03-23 15:17:14 +01:00
parent a9b4f0d842
commit 468fc675a4
4 changed files with 37 additions and 10 deletions

View File

@ -25,11 +25,11 @@ $deletedUsersIndex = new DeletedUsersIndex(
$ocConfig, $dbConnection, $userMapping $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\SetConfig());
$application->add(new OCA\user_ldap\Command\TestConfig()); $application->add(new OCA\user_ldap\Command\TestConfig());
$application->add(new OCA\user_ldap\Command\CreateEmptyConfig()); $application->add(new OCA\user_ldap\Command\CreateEmptyConfig($helper));
$application->add(new OCA\user_ldap\Command\DeleteConfig()); $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\Search($ocConfig));
$application->add(new OCA\user_ldap\Command\ShowRemnants( $application->add(new OCA\user_ldap\Command\ShowRemnants(
$deletedUsersIndex, \OC::$server->getDateTimeFormatter()) $deletedUsersIndex, \OC::$server->getDateTimeFormatter())

View File

@ -17,6 +17,16 @@ use \OCA\user_ldap\lib\Helper;
use \OCA\user_ldap\lib\Configuration; use \OCA\user_ldap\lib\Configuration;
class CreateEmptyConfig extends Command { 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() { protected function configure() {
$this $this
@ -25,7 +35,6 @@ class CreateEmptyConfig extends Command {
; ;
} }
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$configPrefix = $this->getNewConfigurationPrefix(); $configPrefix = $this->getNewConfigurationPrefix();
$output->writeln("Created new configuration with configID '{$configPrefix}'"); $output->writeln("Created new configuration with configID '{$configPrefix}'");
@ -35,7 +44,7 @@ class CreateEmptyConfig extends Command {
} }
protected function getNewConfigurationPrefix() { protected function getNewConfigurationPrefix() {
$serverConnections = Helper::getServerConfigurationPrefixes(); $serverConnections = $this->helper->getServerConfigurationPrefixes();
// first connection uses no prefix // first connection uses no prefix
if(sizeof($serverConnections) == 0) { if(sizeof($serverConnections) == 0) {

View File

@ -11,11 +11,20 @@ namespace OCA\user_ldap\Command;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use \OCA\user_ldap\lib\Helper; use \OCA\user_ldap\lib\Helper;
class DeleteConfig extends Command { 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() { protected function configure() {
$this $this
@ -31,9 +40,9 @@ class DeleteConfig extends Command {
protected function execute(InputInterface $input, OutputInterface $output) { 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) { if($success) {
$output->writeln("Deleted configuration with configID '{$configPrefix}'"); $output->writeln("Deleted configuration with configID '{$configPrefix}'");

View File

@ -17,6 +17,16 @@ use \OCA\user_ldap\lib\Helper;
use \OCA\user_ldap\lib\Configuration; use \OCA\user_ldap\lib\Configuration;
class ShowConfig extends Command { 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() { protected function configure() {
$this $this
@ -37,8 +47,7 @@ class ShowConfig extends Command {
} }
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$helper = new Helper(); $availableConfigs = $this->helper->getServerConfigurationPrefixes();
$availableConfigs = $helper->getServerConfigurationPrefixes();
$configID = $input->getArgument('configID'); $configID = $input->getArgument('configID');
if(!is_null($configID)) { if(!is_null($configID)) {
$configIDs[] = $configID; $configIDs[] = $configID;