Move isBackend logic to App\Mode
This commit is contained in:
parent
425876316f
commit
cba9fa2467
4 changed files with 82 additions and 31 deletions
32
src/App.php
32
src/App.php
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue