mirror of
https://github.com/friendica/friendica
synced 2025-01-03 14:42:18 +00:00
replace calls for App::getBasePath() with AppHelper
This commit is contained in:
parent
79f9e78daf
commit
ae75ffc31a
7 changed files with 26 additions and 23 deletions
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Friendica\Console;
|
namespace Friendica\Console;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\AppHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When I installed docblox, I had the experience that it does not generate any output at all.
|
* When I installed docblox, I had the experience that it does not generate any output at all.
|
||||||
|
@ -33,14 +33,14 @@ class DocBloxErrorChecker extends \Asika\SimpleConsole\Console
|
||||||
|
|
||||||
protected $helpOptions = ['h', 'help', '?'];
|
protected $helpOptions = ['h', 'help', '?'];
|
||||||
|
|
||||||
/** @var App */
|
/** @var string */
|
||||||
private $app;
|
private $basePath;
|
||||||
|
|
||||||
public function __construct(App $app, array $argv = null)
|
public function __construct(AppHelper $appHelper, array $argv = null)
|
||||||
{
|
{
|
||||||
parent::__construct($argv);
|
parent::__construct($argv);
|
||||||
|
|
||||||
$this->app = $app;
|
$this->basePath = $appHelper->getBasePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getHelp()
|
protected function getHelp()
|
||||||
|
@ -73,7 +73,7 @@ HELP;
|
||||||
throw new \RuntimeException('DocBlox isn\'t available.');
|
throw new \RuntimeException('DocBlox isn\'t available.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = $this->app->getBasePath();
|
$dir = $this->basePath;
|
||||||
|
|
||||||
//stack for dirs to search
|
//stack for dirs to search
|
||||||
$dirstack = [];
|
$dirstack = [];
|
||||||
|
|
|
@ -7,10 +7,11 @@
|
||||||
|
|
||||||
namespace Friendica\Console;
|
namespace Friendica\Console;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App\Mode;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Update;
|
use Friendica\Core\Update;
|
||||||
|
use Friendica\DI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs database post updates
|
* Performs database post updates
|
||||||
|
@ -20,7 +21,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console
|
||||||
protected $helpOptions = ['h', 'help', '?'];
|
protected $helpOptions = ['h', 'help', '?'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var App\Mode
|
* @var Mode
|
||||||
*/
|
*/
|
||||||
private $appMode;
|
private $appMode;
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +32,10 @@ class PostUpdate extends \Asika\SimpleConsole\Console
|
||||||
* @var L10n
|
* @var L10n
|
||||||
*/
|
*/
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $basePath;
|
||||||
|
|
||||||
protected function getHelp()
|
protected function getHelp()
|
||||||
{
|
{
|
||||||
|
@ -46,19 +51,18 @@ HELP;
|
||||||
return $help;
|
return $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(App\Mode $appMode, IManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null)
|
public function __construct(Mode $appMode, IManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null)
|
||||||
{
|
{
|
||||||
parent::__construct($argv);
|
parent::__construct($argv);
|
||||||
|
|
||||||
$this->appMode = $appMode;
|
$this->appMode = $appMode;
|
||||||
$this->keyValue = $keyValue;
|
$this->keyValue = $keyValue;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
$this->basePath = DI::apphelper()->getBasePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doExecute(): int
|
protected function doExecute(): int
|
||||||
{
|
{
|
||||||
$a = \Friendica\DI::app();
|
|
||||||
|
|
||||||
if ($this->getOption($this->helpOptions)) {
|
if ($this->getOption($this->helpOptions)) {
|
||||||
$this->out($this->getHelp());
|
$this->out($this->getHelp());
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -79,7 +83,7 @@ HELP;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->l10n->t('Check for pending update actions.') . "\n";
|
echo $this->l10n->t('Check for pending update actions.') . "\n";
|
||||||
Update::run($a->getBasePath(), true, false, true, false);
|
Update::run($this->basePath, true, false, true, false);
|
||||||
echo $this->l10n->t('Done.') . "\n";
|
echo $this->l10n->t('Done.') . "\n";
|
||||||
|
|
||||||
echo $this->l10n->t('Execute pending post updates.') . "\n";
|
echo $this->l10n->t('Execute pending post updates.') . "\n";
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Hook
|
||||||
*/
|
*/
|
||||||
public static function register(string $hook, string $file, string $function, int $priority = 0)
|
public static function register(string $hook, string $file, string $function, int $priority = 0)
|
||||||
{
|
{
|
||||||
$file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
|
$file = str_replace(DI::apphelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
|
||||||
|
|
||||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||||
if (DBA::exists('hook', $condition)) {
|
if (DBA::exists('hook', $condition)) {
|
||||||
|
@ -102,7 +102,7 @@ class Hook
|
||||||
*/
|
*/
|
||||||
public static function unregister(string $hook, string $file, string $function): bool
|
public static function unregister(string $hook, string $file, string $function): bool
|
||||||
{
|
{
|
||||||
$relative_file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
|
$relative_file = str_replace(DI::apphelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
|
||||||
|
|
||||||
// This here is only needed for fixing a problem that existed on the develop branch
|
// This here is only needed for fixing a problem that existed on the develop branch
|
||||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||||
|
@ -198,7 +198,7 @@ class Hook
|
||||||
public static function callSingle(string $name, array $hook, &$data = null)
|
public static function callSingle(string $name, array $hook, &$data = null)
|
||||||
{
|
{
|
||||||
// Don't run a theme's hook if the user isn't using the theme
|
// Don't run a theme's hook if the user isn't using the theme
|
||||||
if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . DI::app()->getCurrentTheme()) === false) {
|
if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . DI::apphelper()->getCurrentTheme()) === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Summary extends BaseAdmin
|
||||||
{
|
{
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
$a = DI::app();
|
$basePath = DI::apphelper()->getBasePath();
|
||||||
|
|
||||||
// are there MyISAM tables in the DB? If so, trigger a warning message
|
// are there MyISAM tables in the DB? If so, trigger a warning message
|
||||||
$warningtext = [];
|
$warningtext = [];
|
||||||
|
@ -120,7 +120,7 @@ class Summary extends BaseAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
// check legacy basepath settings
|
// check legacy basepath settings
|
||||||
$configLoader = (new Config())->createConfigFileManager($a->getBasePath(), $_SERVER);
|
$configLoader = (new Config())->createConfigFileManager($basePath, $_SERVER);
|
||||||
$configCache = new Cache();
|
$configCache = new Cache();
|
||||||
$configLoader->setupCache($configCache);
|
$configLoader->setupCache($configCache);
|
||||||
$confBasepath = $configCache->get('system', 'basepath');
|
$confBasepath = $configCache->get('system', 'basepath');
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Home extends BaseModule
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
$app = DI::app();
|
$basePath = DI::apphelper()->getBasePath();
|
||||||
$config = DI::config();
|
$config = DI::config();
|
||||||
|
|
||||||
// currently no returned data is used
|
// currently no returned data is used
|
||||||
|
@ -51,8 +51,8 @@ class Home extends BaseModule
|
||||||
$customHome = '';
|
$customHome = '';
|
||||||
$defaultHeader = ($config->get('config', 'sitename') ? DI::l10n()->t('Welcome to %s', $config->get('config', 'sitename')) : '');
|
$defaultHeader = ($config->get('config', 'sitename') ? DI::l10n()->t('Welcome to %s', $config->get('config', 'sitename')) : '');
|
||||||
|
|
||||||
$homeFilePath = $app->getBasePath() . '/home.html';
|
$homeFilePath = $basePath . '/home.html';
|
||||||
$cssFilePath = $app->getBasePath() . '/home.css';
|
$cssFilePath = $basePath . '/home.css';
|
||||||
|
|
||||||
if (file_exists($homeFilePath)) {
|
if (file_exists($homeFilePath)) {
|
||||||
$customHome = $homeFilePath;
|
$customHome = $homeFilePath;
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Cron
|
||||||
{
|
{
|
||||||
public static function execute()
|
public static function execute()
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
$basepath = DI::apphelper()->getBasePath();
|
||||||
|
|
||||||
$last = DI::keyValue()->get('last_cron');
|
$last = DI::keyValue()->get('last_cron');
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ class Cron
|
||||||
|
|
||||||
// Ensure to have a .htaccess file.
|
// Ensure to have a .htaccess file.
|
||||||
// this is a precaution for systems that update automatically
|
// this is a precaution for systems that update automatically
|
||||||
$basepath = $a->getBasePath();
|
|
||||||
if (!file_exists($basepath . '/.htaccess') && is_writable($basepath)) {
|
if (!file_exists($basepath . '/.htaccess') && is_writable($basepath)) {
|
||||||
copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
|
copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class DBUpdate
|
||||||
{
|
{
|
||||||
// Just in case the last update wasn't failed
|
// Just in case the last update wasn't failed
|
||||||
if (DI::config()->get('system', 'update', Update::SUCCESS) != Update::FAILED) {
|
if (DI::config()->get('system', 'update', Update::SUCCESS) != Update::FAILED) {
|
||||||
Update::run(DI::app()->getBasePath());
|
Update::run(DI::apphelper()->getBasePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue