Replace Module::init() with Constructors

This commit is contained in:
Philipp 2021-11-17 21:32:57 +01:00
parent de6bb280b1
commit ce578a7745
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
33 changed files with 882 additions and 600 deletions

View file

@ -21,10 +21,12 @@
namespace Friendica\Module\Debug;
use Friendica\App\BaseURL;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
use Friendica\Protocol;
/**
@ -32,11 +34,18 @@ use Friendica\Protocol;
*/
class Feed extends BaseModule
{
public function init()
/** @var ICanSendHttpRequests */
protected $httpClient;
public function __construct(BaseURL $baseUrl, ICanSendHttpRequests $httpClient, L10n $l10n, array $parameters = [])
{
parent::__construct($l10n, $parameters);
$this->httpClient = $httpClient;
if (!local_user()) {
notice(DI::l10n()->t('You must be logged in to use this module'));
DI::baseUrl()->redirect();
notice($this->l10n->t('You must be logged in to use this module'));
$baseUrl->redirect();
}
}
@ -48,7 +57,7 @@ class Feed extends BaseModule
$contact = Model\Contact::getByURLForUser($url, local_user(), null);
$xml = DI::httpClient()->fetch($contact['poll']);
$xml = $this->httpClient->fetch($contact['poll']);
$import_result = Protocol\Feed::import($xml);
@ -60,7 +69,7 @@ class Feed extends BaseModule
$tpl = Renderer::getMarkupTemplate('feedtest.tpl');
return Renderer::replaceMacros($tpl, [
'$url' => ['url', DI::l10n()->t('Source URL'), $_REQUEST['url'] ?? '', ''],
'$url' => ['url', $this->l10n->t('Source URL'), $_REQUEST['url'] ?? '', ''],
'$result' => $result
]);
}