]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Debug/Feed.php
Merge pull request #10994 from nupplaphil/feat/module_constructor
[friendica.git] / src / Module / Debug / Feed.php
index 2d2a7dc54991bf40719d39e846feb14d281a4b70..9368dd0268c05a0d870cbecadf85ace46b8833ab 100644 (file)
 
 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->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->t('Source URL'), $_REQUEST['url'] ?? '', ''],
                        '$result' => $result
                ]);
        }