From a0b37ee9d1c7b36dccf86d5f053ebce3ef40927d Mon Sep 17 00:00:00 2001
From: Marco Schlicht <schlicht@itc.rwth-aachen.de>
Date: Thu, 15 Mar 2018 16:29:21 +0100
Subject: [PATCH] moved static config into it's own file

---
 src/RwthMoodleApiLib/Config.php            | 49 ++++++++++++++++++++++
 src/RwthMoodleApiLib/Injector/Injector.php |  7 +++-
 2 files changed, 54 insertions(+), 2 deletions(-)
 create mode 100644 src/RwthMoodleApiLib/Config.php

diff --git a/src/RwthMoodleApiLib/Config.php b/src/RwthMoodleApiLib/Config.php
new file mode 100644
index 0000000..27b12a1
--- /dev/null
+++ b/src/RwthMoodleApiLib/Config.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * The Moodle Webservice API Wrapper of the Rwth Aachen University
+ *
+ * PHP Version 7.0
+ *
+ * RwthMoodleApiLib
+ * Copyright (C) 2017 Marco Schlicht PIT RWTH Aachen
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  RwthMoodleApiLib
+ * @package   RwthMoodleApiLib
+ * @author    Marco Schlicht <marcoschlicht@onlinehome.de>
+ * @copyright 2017 Marco Schlicht PIT RWTH Aachen
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @link      https://git.rwth-aachen.de/moodle/rwth_moodle_api
+ **/
+
+namespace RwthMoodleApiLib;
+
+/**
+ * Config File
+ *
+ * @category  Config
+ * @package   RwthMoodleApiLib
+ * @author    Marco Schlicht <marcoschlicht@onlinehome.de>
+ * @copyright 2017 Marco Schlicht PIT RWTH Aachen
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @link      https://git.rwth-aachen.de/moodle/rwth_moodle_api
+ **/
+namespace RwthMoodleApiLib;
+
+class Config
+{
+	public static $moodle_url = "https://d-mo01.devlef.campus.rwth-aachen.de/moodlems/";
+}
+?>
diff --git a/src/RwthMoodleApiLib/Injector/Injector.php b/src/RwthMoodleApiLib/Injector/Injector.php
index e5e8e25..0eb8654 100644
--- a/src/RwthMoodleApiLib/Injector/Injector.php
+++ b/src/RwthMoodleApiLib/Injector/Injector.php
@@ -56,7 +56,7 @@ class Injector implements InjectorInterface
 	/**
 	 * Constructor
 	 **/
-	public function __construct()
+	public function __construct($url=Null)
 	{
 		//observers
 		$informationalObserver = new Logging\ConsoleLogger(6);
@@ -75,7 +75,10 @@ class Injector implements InjectorInterface
 		//http client
 		//needs an / at the end
 		//TODO throw error if not or rebuild the uri
-		$this->httpClient = new Http\Client($this->loggingManager, ["base_uri" => "http://localhost/moodle/"]);
+		if (is_null($url)) {
+			$url = RwthMoodleApiLib\Config::$moodle_url;
+		}
+		$this->httpClient = new Http\Client($this->loggingManager, ["base_uri" => $url]);
 		//rwth moodle api
 		$this->rwthMoodleApiLib = new RwthMoodleApiLib\RwthMoodleApiLib($this->loggingManager, $this->httpClient);
 	}
-- 
GitLab