mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Changing Friendica\App\Mode from static methods to public methods
- Changing from static methods to public methods - Adding dev-composer-dependency Mockery for static method mocking (f.e. Config, DBA) - Adding ModeTest with Mocking - removing bootstrap from phpunit.xml because of double loading tests\bootstrap.php
This commit is contained in:
parent
5014779052
commit
31148e25cf
21 changed files with 498 additions and 106 deletions
30
src/App.php
30
src/App.php
|
@ -11,6 +11,7 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
|
||||
require_once 'boot.php';
|
||||
require_once 'include/dba.php';
|
||||
|
@ -83,6 +84,11 @@ class App
|
|||
public $stylesheets = [];
|
||||
public $footerScripts = [];
|
||||
|
||||
/**
|
||||
* @var App\Mode The Mode of the Application
|
||||
*/
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* Register a stylesheet file path to be included in the <head> tag of every page.
|
||||
* Inclusion is done in App->initHead().
|
||||
|
@ -193,6 +199,8 @@ class App
|
|||
$this->callstack['rendering'] = [];
|
||||
$this->callstack['parser'] = [];
|
||||
|
||||
$this->mode = new App\Mode($basepath);
|
||||
|
||||
$this->reload();
|
||||
|
||||
set_time_limit(0);
|
||||
|
@ -300,6 +308,22 @@ class App
|
|||
$this->register_template_engine('Friendica\Render\FriendicaSmartyEngine');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Mode of the Application
|
||||
*
|
||||
* @return App\Mode The Application Mode
|
||||
*
|
||||
* @throws InternalServerErrorException when the mode isn't created
|
||||
*/
|
||||
public function getMode()
|
||||
{
|
||||
if (empty($this->mode)) {
|
||||
throw new InternalServerErrorException('Mode of the Application is not defined');
|
||||
}
|
||||
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the whole app instance
|
||||
*/
|
||||
|
@ -310,13 +334,13 @@ class App
|
|||
|
||||
$this->loadDatabase();
|
||||
|
||||
App\Mode::determine($this->basepath);
|
||||
$this->getMode()->determine($this->basepath);
|
||||
|
||||
$this->determineUrlPath();
|
||||
|
||||
Config::load();
|
||||
|
||||
if (App\Mode::has(App\Mode::DBAVAILABLE)) {
|
||||
if ($this->getMode()->has(App\Mode::DBAVAILABLE)) {
|
||||
Core\Addon::loadHooks();
|
||||
|
||||
$this->loadAddonConfig();
|
||||
|
@ -1402,7 +1426,7 @@ class App
|
|||
*/
|
||||
public function getCurrentTheme()
|
||||
{
|
||||
if (App\Mode::isInstall()) {
|
||||
if ($this->getMode()->isInstall()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue