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.
protected $helpOptions = ['h', 'help', '?'];
- /** @var App */
- private $app;
+ /** @var string */
+ private $basePath;
- public function __construct(App $app, array $argv = null)
+ public function __construct(AppHelper $appHelper, array $argv = null)
{
parent::__construct($argv);
- $this->app = $app;
+ $this->basePath = $appHelper->getBasePath();
}
protected function getHelp()
throw new \RuntimeException('DocBlox isn\'t available.');
}
- $dir = $this->app->getBasePath();
+ $dir = $this->basePath;
//stack for dirs to search
$dirstack = [];
namespace Friendica\Console;
-use Friendica\App;
+use Friendica\App\Mode;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
use Friendica\Core\L10n;
use Friendica\Core\Update;
+use Friendica\DI;
/**
* Performs database post updates
protected $helpOptions = ['h', 'help', '?'];
/**
- * @var App\Mode
+ * @var Mode
*/
private $appMode;
/**
* @var L10n
*/
private $l10n;
+ /**
+ * @var string
+ */
+ private $basePath;
protected function getHelp()
{
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);
$this->appMode = $appMode;
$this->keyValue = $keyValue;
$this->l10n = $l10n;
+ $this->basePath = DI::apphelper()->getBasePath();
}
protected function doExecute(): int
{
- $a = \Friendica\DI::app();
-
if ($this->getOption($this->helpOptions)) {
$this->out($this->getHelp());
return 0;
}
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('Execute pending post updates.') . "\n";
*/
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];
if (DBA::exists('hook', $condition)) {
*/
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
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
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
- 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;
}
{
parent::content();
- $a = DI::app();
+ $basePath = DI::apphelper()->getBasePath();
// are there MyISAM tables in the DB? If so, trigger a warning message
$warningtext = [];
}
// check legacy basepath settings
- $configLoader = (new Config())->createConfigFileManager($a->getBasePath(), $_SERVER);
+ $configLoader = (new Config())->createConfigFileManager($basePath, $_SERVER);
$configCache = new Cache();
$configLoader->setupCache($configCache);
$confBasepath = $configCache->get('system', 'basepath');
protected function content(array $request = []): string
{
- $app = DI::app();
+ $basePath = DI::apphelper()->getBasePath();
$config = DI::config();
// currently no returned data is used
$customHome = '';
$defaultHeader = ($config->get('config', 'sitename') ? DI::l10n()->t('Welcome to %s', $config->get('config', 'sitename')) : '');
- $homeFilePath = $app->getBasePath() . '/home.html';
- $cssFilePath = $app->getBasePath() . '/home.css';
+ $homeFilePath = $basePath . '/home.html';
+ $cssFilePath = $basePath . '/home.css';
if (file_exists($homeFilePath)) {
$customHome = $homeFilePath;
{
public static function execute()
{
- $a = DI::app();
+ $basepath = DI::apphelper()->getBasePath();
$last = DI::keyValue()->get('last_cron');
// Ensure to have a .htaccess file.
// this is a precaution for systems that update automatically
- $basepath = $a->getBasePath();
if (!file_exists($basepath . '/.htaccess') && is_writable($basepath)) {
copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
}
{
// Just in case the last update wasn't failed
if (DI::config()->get('system', 'update', Update::SUCCESS) != Update::FAILED) {
- Update::run(DI::app()->getBasePath());
+ Update::run(DI::apphelper()->getBasePath());
}
}
}