3 namespace Org\Mxchange\CoreFramework\Bootstrap;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
7 use Org\Mxchange\CoreFramework\Connection\Database\DatabaseConnection;
8 use Org\Mxchange\CoreFramework\Connector\Database\DatabaseConnector;
9 use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
10 use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
11 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
12 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
13 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
14 use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
15 use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
16 use Org\Mxchange\CoreFramework\Loader\ClassLoader;
17 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
18 use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
19 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
20 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
21 use Org\Mxchange\CoreFramework\Request\Requestable;
22 use Org\Mxchange\CoreFramework\Response\Responseable;
23 use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
26 use \BadMethodCallException;
27 use \InvalidArgumentException;
31 * A framework-bootstrap class which helps the frameworks to bootstrap ... ;-)
33 * @author Roland Haeder <webmaster@ship-simu.org>
35 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
36 * @license GNU GPL 3.0 or any newer version
37 * @link http://www.ship-simu.org
39 * This program is free software: you can redistribute it and/or modify
40 * it under the terms of the GNU General Public License as published by
41 * the Free Software Foundation, either version 3 of the License, or
42 * (at your option) any later version.
44 * This program is distributed in the hope that it will be useful,
45 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 * GNU General Public License for more details.
49 * You should have received a copy of the GNU General Public License
50 * along with this program. If not, see <http://www.gnu.org/licenses/>.
52 final class FrameworkBootstrap {
55 * Detected server address
57 private static $serverAddress = NULL;
60 * Instance of a Requestable class
62 private static $requestInstance = NULL;
65 * Instance of a Responseable class
67 private static $responseInstance = NULL;
70 * Instance of a FrameworkConfiguration class
72 private static $configurationInstance = NULL;
77 private static $databaseInstance = NULL;
80 * Language system instance
82 private static $languageInstance = NULL;
85 * Includes applications may have. They will be tried in the given order,
86 * some will become soon deprecated.
88 private static $configAppIncludes = [
89 // The ApplicationHelper class (required)
90 'class_ApplicationHelper' => 'required',
91 // Some debugging stuff (optional but can be committed)
92 'debug' => 'optional',
93 // Application's exception handler (optional but can be committed)
94 'exceptions' => 'optional',
95 // Application's configuration file (committed, non-local specific)
96 'config' => 'required',
97 // Local configuration file (optional, not committed, listed in .gitignore)
98 'config-local' => 'optional',
99 // Application data (deprecated)
100 'data' => 'deprecated',
101 // Application loader (deprecated)
102 'loader' => 'deprecated',
103 // Application initializer (deprecated)
104 'init' => 'deprecated',
105 // Application starter (deprecated)
106 'starter' => 'deprecated',
110 * Detected application's name
112 private static $detectedApplicationName;
115 * Detected application's full path
117 private static $detectedApplicationPath;
120 * Private constructor, no instance is needed from this class as only
121 * static methods exist.
123 private function __construct () {
124 // Prevent making instances from this "utilities" class
128 * Some "getter" for a configuration instance, making sure, it is unique
130 * @return $configurationInstance An instance of a FrameworkConfiguration class
132 public static function getConfigurationInstance () {
133 // Is the instance there?
134 if (is_null(self::$configurationInstance)) {
136 self::$configurationInstance = new FrameworkConfiguration();
140 return self::$configurationInstance;
144 * Getter for detected application name
146 * @return $detectedApplicationName Detected name of application
148 public static function getDetectedApplicationName () {
149 return self::$detectedApplicationName;
153 * Getter for detected application's full path
155 * @return $detectedApplicationPath Detected full path of application
157 public static function getDetectedApplicationPath () {
158 return self::$detectedApplicationPath;
162 * "Getter" to get response/request type from analysis of the system.
164 * @return $requestType Analyzed request type
166 public static function getRequestTypeFromSystem () {
167 // Default is console
168 $requestType = 'console';
170 // Is 'HTTP_HOST' set?
171 if (isset($_SERVER['HTTP_HOST'])) {
172 // Then it is a HTML response/request.
173 $requestType = 'html';
181 * Checks whether the given file/path is in open_basedir(). This does not
182 * gurantee that the file is actually readable and/or writeable. If you need
183 * such gurantee then please use isReadableFile() instead.
185 * @param $fileInstance An instance of a SplFileInfo class
186 * @return $isReachable Whether it is within open_basedir()
188 public static function isReachableFilePath (SplFileInfo $fileInstance) {
189 // Is not reachable by default
190 //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, get_class($fileInstance));
191 $isReachable = false;
193 // Get open_basedir parameter
194 $openBaseDir = trim(ini_get('open_basedir'));
197 //* NOISY-DEBUG: */ printf('[%s:%d]: openBaseDir=%s' . PHP_EOL, __METHOD__, __LINE__, $openBaseDir);
198 if (!empty($openBaseDir)) {
200 foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) {
201 // Check on existence
202 //* NOISY-DEBUG: */ printf('[%s:%d]: dir=%s' . PHP_EOL, __METHOD__, __LINE__, $dir);
203 if (substr($fileInstance->getPathname(), 0, strlen($dir)) == $dir) {
207 // Abort lookup as it has been found in open_basedir
208 //* NOISY-DEBUG: */ printf('[%s:%d]: BREAK!' . PHP_EOL, __METHOD__, __LINE__);
213 // If open_basedir is not set, all is allowed
214 //* NOISY-DEBUG: */ printf('[%s:%d]: All is allowed - BREAK!' . PHP_EOL, __METHOD__, __LINE__);
219 //* NOISY-DEBUG: */ printf('[%s:%d]: isReachable=%d - EXIT' . PHP_EOL, __METHOD__, __LINE__, intval($isReachable));
224 * Checks whether the give file is within open_basedir() (done by
225 * isReachableFilePath()), is actually a file and is readable.
227 * @param $fileInstance An instance of a SplFileInfo class
228 * @return $isReadable Whether the file is readable (and therefor exists)
230 public static function isReadableFile (SplFileInfo $fileInstance) {
231 // Default is not readable
234 // Check if it is a file and readable
237 self::isReachableFilePath($fileInstance)
239 $fileInstance->isFile()
241 $fileInstance->isReadable()
250 * Loads given include file
252 * @param $fileInstance An instance of a SplFileInfo class
254 * @throws InvalidArgumentException If file was not found or not readable or deprecated
256 public static function loadInclude (SplFileInfo $fileInstance) {
257 // Should be there ...
258 //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance->__toString());
259 if (!self::isReadableFile($fileInstance)) {
261 throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
262 } elseif (!$fileInstance->isFile()) {
264 throw new InvalidArgumentException(sprintf('fileInstance.pathname=%s is not a file', $fileInstance->getPathname()));
265 } elseif (substr($fileInstance->__toString(), -4, 4) != '.php') {
267 throw new InvalidArgumentException(sprintf('fileInstance.pathname=%s is not a PHP script', $fileInstance->getPathname()));
271 require_once $fileInstance->getPathname();
274 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
278 * Does the actual bootstrap. I think the amount of statically loaded
279 * include files cannot be reduced here as those files are need to early
280 * in the bootstrap phase. If you can find an other solution than this, with
281 * lesser "static includes" (means not loaded by the class loader), please
286 public static function doBootstrap () {
287 // Load basic include files to continue bootstrapping
288 //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
289 self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
290 self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sclass_BaseFrameworkSystem.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
291 self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sutils%sstrings%sclass_StringUtils.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
292 self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
293 self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
295 // Load global configuration
296 self::loadInclude(new SplFileInfo(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php')));
299 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
303 * Initializes the framework by scanning for all framework-relevant
304 * classes, interfaces and exception. Then determine the request type and
305 * initialize a Requestable instance which will then contain all request
306 * parameter, also from CLI. Next step is to validate the application
311 public static function initFramework () {
313 * 1) Load class loader and scan framework classes, interfaces and
316 self::scanFrameworkClasses();
319 * 2) Determine the request type, console or web and store request and
320 * response here. This also initializes the request instance with
321 * all given parameters (see doc-tag for possible sources of
324 self::determineRequestType();
327 * 3) Now, that there are all request parameters being available, check
328 * if 'application' is supplied. If it is not found, abort execution, if
329 * found, continue below with next step.
331 self::validateApplicationParameter();
335 * Initializes the detected application. This may fail if required files
336 * are not found in the application's base path (not to be confused with
337 * 'application_base_path' which only points to /some/foo/application/.
341 public static function prepareApplication () {
343 * Now check and load all files, found deprecated files will throw a
344 * warning at the user.
346 /* NOISY-DEBUG: */ printf('[%s:%d]: self::configAppIncludes()=%d' . PHP_EOL, __METHOD__, __LINE__, count(self::$configAppIncludes));
347 foreach (self::$configAppIncludes as $fileName => $status) {
348 // Construct file instance
349 //* NOISY-DEBUG: */ printf('[%s:%d]: fileName=%s,status=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $status);
350 $fileInstance = new SplFileInfo(sprintf('%s%s.php', self::getDetectedApplicationPath(), $fileName));
352 // Determine if this file is wanted/readable/deprecated
353 if (($status == 'required') && (!self::isReadableFile($fileInstance))) {
354 // Nope, required file cannot be found/read from
355 ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', self::getDetectedApplicationName(), $fileInstance->getBasename()));
356 } elseif (($fileInstance->isFile()) && (!$fileInstance->isReadable())) {
357 // Found, not readable file
358 ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), self::getDetectedApplicationName()));
359 } elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
360 // Not found but optional/deprecated file, skip it
361 //* NOISY-DEBUG: */ printf('[%s:%d]: fileName=%s,status=%s - SKIPPED!' . PHP_EOL, __METHOD__, __LINE__, $fileName, $status);
365 // Is the file deprecated?
366 if ($status == 'deprecated') {
368 trigger_error(sprintf('Deprecated file "%s.php" found, will not load it to avoid problems. Please remove it from your application "%s" to avoid this warning.', $fileName, self::getDetectedApplicationName()), E_USER_WARNING);
370 // Skip loading deprecated file
375 //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking self::loadInclude(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $fileInstance->__toString());
376 self::loadInclude($fileInstance);
379 // After this, sort the configuration array
380 self::getConfigurationInstance()->sortConfigurationArray();
382 // Scan for application's classes, exceptions and interfaces
383 ClassLoader::scanApplicationClasses();
387 * Starts a fully initialized application, the class ApplicationHelper must
388 * be loaded at this point.
392 public static function startApplication () {
393 // Is there an application helper instance?
394 //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
395 $applicationInstance = call_user_func_array(
397 'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
401 // Some sanity checks
402 //* NOISY-DEBUG: */ printf('[%s:%d]: applicationInstance=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationInstance->__toString());
403 if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
404 // Something went wrong!
405 ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
406 self::getDetectedApplicationName(),
407 'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper'
409 } elseif (!is_object($applicationInstance)) {
411 ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because 'app' is not an object (%s).',
412 self::getDetectedApplicationName(),
413 gettype($applicationInstance)
415 } elseif (!($applicationInstance instanceof ManageableApplication)) {
417 ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because 'app' is lacking required interface ManageableApplication.',
418 self::getDetectedApplicationName()
422 // Now call all methods in one go
423 //* NOISY-DEBUG: */ printf('[%s:%d]: Initializing application ...' . PHP_EOL, __METHOD__, __LINE__);
424 foreach (['setupApplicationData', 'initApplication', 'launchApplication'] as $methodName) {
426 //*NOISY-DEBUG: */ printf('[%s:%d]: Invoking methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
427 call_user_func([$applicationInstance, $methodName]);
431 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
435 * Initializes database instance, no need to double-call this method
439 public static function initDatabaseInstance () {
440 // Get application instance
441 $applicationInstance = ApplicationHelper::getSelfInstance();
443 // Is the database instance already set?
444 if (self::getDatabaseInstance() instanceof DatabaseConnector) {
445 // Yes, then abort here
446 throw new BadMethodCallException('Method called twice.');
449 // Initialize database layer
450 $databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
452 // Prepare database instance
453 $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
455 // Set it in application helper
456 self::setDatabaseInstance($connectionInstance);
460 * Detects the server address (SERVER_ADDR) and set it in configuration
462 * @return $serverAddress The detected server address
463 * @throws UnknownHostnameException If SERVER_NAME cannot be resolved to an IP address
464 * @todo Have to check some more entries from $_SERVER here
466 public static function detectServerAddress () {
468 if (!isset(self::$serverAddress)) {
469 // Is it set in $_SERVER?
470 if (!empty($_SERVER['SERVER_ADDR'])) {
471 // Set it from $_SERVER
472 self::$serverAddress = $_SERVER['SERVER_ADDR'];
473 } elseif (isset($_SERVER['SERVER_NAME'])) {
474 // Resolve IP address
475 $serverIp = ConsoleTools::resolveIpAddress($_SERVER['SERVER_NAME']);
478 if ($serverIp === false) {
480 * Why is gethostbyname() returning the host name and not
481 * false as many other PHP functions are doing? ;-(
483 throw new UnknownHostnameException(sprintf('Cannot resolve "%s" to an IP address. Please fix your setup.', $_SERVER['SERVER_NAME']));
487 self::$serverAddress = $serverIp;
489 // Run auto-detecting through console tools lib
490 self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
495 return self::$serverAddress;
499 * Setter for default time zone (must be correct!)
501 * @param $timezone The timezone string (e.g. Europe/Berlin)
502 * @return $success If timezone was accepted
503 * @throws InvalidArgumentException If $timezone is empty
505 public static function setDefaultTimezone (string $timezone) {
507 if (empty($timezone)) {
509 throw new InvalidArgumentException('Parameter "timezone" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
516 * Set desired time zone to prevent date() and related functions to
517 * issue an E_WARNING.
519 $success = date_default_timezone_set($timezone);
526 * Checks whether HTTPS is set in $_SERVER
528 * @return $isset Whether HTTPS is set
529 * @todo Test more fields
531 public static function isHttpSecured () {
535 isset($_SERVER['HTTPS'])
537 strtolower($_SERVER['HTTPS']) == 'on'
541 isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
543 strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
550 * Dectect and return the base URL for all URLs and forms
552 * @return $baseUrl Detected base URL
554 public static function detectBaseUrl () {
555 // Initialize the URL
559 if (self::isHttpSecured()) {
560 // Add the >s< for HTTPS
564 // Construct the full URL and secure it against CSRF attacks
565 $baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
572 * Detect safely and return the full domain where this script is installed
574 * @return $fullDomain The detected full domain
576 public static function detectDomain () {
577 // Full domain is localnet.invalid by default
578 $fullDomain = 'localnet.invalid';
580 // Is the server name there?
581 if (isset($_SERVER['SERVER_NAME'])) {
582 // Detect the full domain
583 $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
591 * Detect safely the script path without trailing slash which is the glue
592 * between "http://your-domain.invalid/" and "script-name.php"
594 * @return $scriptPath The script path extracted from $_SERVER['SCRIPT_NAME']
596 public static function detectScriptPath () {
600 // Is the scriptname set?
601 if (isset($_SERVER['SCRIPT_NAME'])) {
602 // Get dirname from it and replace back-slashes with slashes for lame OSes...
603 $scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME']));
611 * 1) Loads class scanner and scans all framework's classes and interfaces.
612 * This method also registers the class loader's method autoLoad() for the
613 * SPL auto-load feature. Remember that you can register additional methods
614 * (not functions, please) for other libraries.
616 * Yes, I know about Composer, but I like to keep my class loader around.
617 * You can always use mine as long as your classes have a namespace
618 * according naming-convention: Vendor\Project\Group[\SubGroup]
622 private static function scanFrameworkClasses () {
623 // Include class loader
624 require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
626 // Register auto-load function with the SPL
627 spl_autoload_register('Org\Mxchange\CoreFramework\Loader\ClassLoader::autoLoad');
629 // Scan for all framework classes, exceptions and interfaces
630 ClassLoader::scanFrameworkClasses();
634 * 2) Determines request/response type and stores the created
635 * request/response instances in this object for later usage.
639 private static function determineRequestType () {
640 // Determine request type
641 $request = self::getRequestTypeFromSystem();
642 $requestType = self::getRequestTypeFromSystem();
644 // Create a new request object
645 $requestInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Request\%sRequest', StringUtils::convertToClassName($request)));
647 // Remember request instance here
648 self::setRequestInstance($requestInstance);
650 // Do we have another response?
651 if ($requestInstance->isRequestElementSet('request')) {
653 $request = strtolower($requestInstance->getRequestElement('request'));
654 $requestType = $request;
657 // ... and a new response object
658 $responseInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request)));
660 // Remember response instance here
661 self::setResponseInstance($responseInstance);
665 * 3) Validate parameter 'application' if it is set and the application is there.
669 private static function validateApplicationParameter () {
670 // Is the parameter set?
671 if (!self::getRequestInstance()->isRequestElementSet('app')) {
673 * Don't continue here, the application 'selector' is no longer
674 * supported and only existed as an idea to select the proper
675 * application (by user).
677 ApplicationEntryPoint::exitApplication('No application specified. Please provide a parameter "app" and retry.');
680 // Get it for local usage
681 $applicationName = self::getRequestInstance()->getRequestElement('app');
683 // Secure it, by keeping out tags
684 $applicationName = htmlentities(strip_tags($applicationName), ENT_QUOTES);
686 // Secure it a little more with a reg.exp.
687 $applicationName = preg_replace('/([^a-z0-9_-])+/i', '', $applicationName);
689 // Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
690 $applicationPath = sprintf(
692 self::getConfigurationInstance()->getConfigEntry('application_base_path'),
697 // Full path for application
698 // Is the path there? This secures a bit the parameter (from untrusted source).
699 if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
700 // Not found or not readable
701 ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $applicationName));
704 // Set the detected application's name and full path for later usage
705 self::$detectedApplicationPath = $applicationPath;
706 self::$detectedApplicationName = $applicationName;
710 * Getter for request instance
712 * @return $requestInstance An instance of a Requestable class
714 public static function getRequestInstance () {
715 return self::$requestInstance;
719 * Getter for response instance
721 * @return $responseInstance An instance of a Responseable class
723 public static function getResponseInstance () {
724 return self::$responseInstance;
728 * Setter for request instance
730 * @param $requestInstance An instance of a Requestable class
733 private static function setRequestInstance (Requestable $requestInstance) {
734 self::$requestInstance = $requestInstance;
738 * Setter for response instance
740 * @param $responseInstance An instance of a Responseable class
743 private static function setResponseInstance (Responseable $responseInstance) {
744 self::$responseInstance = $responseInstance;
748 * Setter for database instance
750 * @param $databaseInstance An instance of a DatabaseConnection class
753 public static function setDatabaseInstance (DatabaseConnection $databaseInstance) {
754 self::$databaseInstance = $databaseInstance;
758 * Getter for database instance
760 * @return $databaseInstance An instance of a DatabaseConnection class
762 public static function getDatabaseInstance () {
764 return self::$databaseInstance;
768 * Private getter for language instance
770 * @return $languageInstance An instance of a ManageableLanguage class
772 public static function getLanguageInstance () {
773 return self::$languageInstance;
777 * Setter for language instance
779 * @param $languageInstance An instance of a ManageableLanguage class
782 public static function setLanguageInstance (ManageableLanguage $languageInstance) {
783 self::$languageInstance = $languageInstance;