<?php
/**
* @file bin/worker.php
- * @brief Starts the background processing
+ * Starts the background processing
*/
+use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Core\Config\Cache;
use Friendica\Core\Update;
use Friendica\Core\Worker;
-use Friendica\Factory;
-use Friendica\Util\BasePath;
+use Friendica\DI;
+use Psr\Log\LoggerInterface;
// Get options
$shortopts = 'sn';
require dirname(__DIR__) . '/vendor/autoload.php';
-$basedir = BasePath::create(dirname(__DIR__), $_SERVER);
-$configLoader = new Cache\ConfigCacheLoader($basedir);
-$configCache = Factory\ConfigFactory::createCache($configLoader);
-Factory\DBFactory::init($configCache, $_SERVER);
-$config = Factory\ConfigFactory::createConfig($configCache);
-// needed to call PConfig::init()
-Factory\ConfigFactory::createPConfig($configCache);
-$logger = Factory\LoggerFactory::create('worker', $config);
-$profiler = Factory\ProfilerFactory::create($logger, $config);
+$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
+$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
-$a = new App($config, $logger, $profiler);
+DI::init($dice);
+$a = DI::app();
// Check the database structure and possibly fixes it
-Update::check($a->getBasePath(), true);
+Update::check($a->getBasePath(), true, DI::mode());
// Quit when in maintenance
-if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
+if (!DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
return;
}
-$a->setBaseURL(Config::get('system', 'url'));
+DI::baseUrl()->saveByURL(DI::config()->get('system', 'url'));
$spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);