1
0
Fork 0

Move isBackend logic to App\Mode

This commit is contained in:
Philipp Holzer 2019-08-15 15:51:15 +02:00
commit cba9fa2467
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
4 changed files with 82 additions and 31 deletions

View file

@ -9,7 +9,6 @@ use DOMDocument;
use DOMXPath;
use Exception;
use Friendica\App\Arguments;
use Friendica\App\Module;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
@ -98,11 +97,6 @@ class App
*/
private $baseURL;
/**
* @var bool true, if the call is from an backend node (f.e. worker)
*/
private $isBackend;
/**
* @var string The name of the current theme
*/
@ -148,11 +142,6 @@ class App
*/
private $args;
/**
* @var App\Module
*/
private $moduleClass;
/**
* Returns the current config cache of this node
*
@ -274,7 +263,7 @@ class App
*
* @throws Exception if the Basepath is not usable
*/
public function __construct(Database $database, Configuration $config, App\Mode $mode, App\Router $router, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Module $module)
public function __construct(Database $database, Configuration $config, App\Mode $mode, App\Router $router, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args)
{
$this->database = $database;
$this->config = $config;
@ -285,7 +274,6 @@ class App
$this->logger = $logger;
$this->l10n = $l10n;
$this->args = $args;
$this->isBackend = $this->checkBackend($module);
$this->profiler->reset();
@ -573,27 +561,17 @@ class App
$this->getBaseURL();
}
/**
* Checks if the site is called via a backend process
*
* @param Module $module The pre-loaded module (just name, not class!)
* @return bool True, if the call is a backend call
*/
private function checkBackend(Module $module)
{
return basename(($_SERVER['PHP_SELF'] ?? ''), '.php') !== 'index' ||
$module->isBackend();
}
/**
* Returns true, if the call is from a backend node (f.e. from a worker)
*
* @return bool Is it a known backend?
*
* @deprecated 2019.09 - use App\Mode->isBackend() instead
* @see App\Mode::isBackend()
*/
public function isBackend()
{
return $this->isBackend;
return $this->mode->isBackend();
}
/**