]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/FriendSuggest.php
"DI" calls are replaced
[friendica.git] / src / Module / FriendSuggest.php
index a53f78cc6d90d6161ad3f797b8b3b28c8476fa70..3cebd72cea580a01607e00fb199c200b21a281a2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -21,7 +21,7 @@
 
 namespace Friendica\Module;
 
-use Friendica\App\BaseURL;
+use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
@@ -31,16 +31,16 @@ use Friendica\Database\Database;
 use Friendica\Model\Contact as ContactModel;
 use Friendica\Network\HTTPException\ForbiddenException;
 use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Util\Profiler;
 use Friendica\Util\Strings;
 use Friendica\Worker\Delivery;
+use Psr\Log\LoggerInterface;
 
 /**
  * Suggest friends to a known contact
  */
 class FriendSuggest extends BaseModule
 {
-       /** @var BaseURL */
-       protected $baseUrl;
        /** @var Database */
        protected $dba;
        /** @var \Friendica\Contact\FriendSuggest\Repository\FriendSuggest */
@@ -48,27 +48,26 @@ class FriendSuggest extends BaseModule
        /** @var \Friendica\Contact\FriendSuggest\Factory\FriendSuggest */
        protected $friendSuggestFac;
 
-       public function __construct(BaseURL $baseUrl, Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, L10n $l10n, array $parameters = [])
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, array $server, array $parameters = [])
        {
-               parent::__construct($l10n, $parameters);
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
                if (!local_user()) {
-                       throw new ForbiddenException($this->l10n->t('Permission denied.'));
+                       throw new ForbiddenException($this->t('Permission denied.'));
                }
 
-               $this->baseUrl           = $baseUrl;
                $this->dba               = $dba;
                $this->friendSuggestRepo = $friendSuggestRepo;
                $this->friendSuggestFac  = $friendSuggestFac;
        }
 
-       public function post()
+       protected function post(array $request = [])
        {
                $cid = intval($this->parameters['contact']);
 
                // We do query the "uid" as well to ensure that it is our contact
                if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => local_user()])) {
-                       throw new NotFoundException($this->l10n->t('Contact not found.'));
+                       throw new NotFoundException($this->t('Contact not found.'));
                }
 
                $suggest_contact_id = intval($_POST['suggest']);
@@ -79,7 +78,7 @@ class FriendSuggest extends BaseModule
                // We do query the "uid" as well to ensure that it is our contact
                $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]);
                if (empty($contact)) {
-                       notice($this->l10n->t('Suggested contact not found.'));
+                       notice($this->t('Suggested contact not found.'));
                        return;
                }
 
@@ -97,16 +96,16 @@ class FriendSuggest extends BaseModule
 
                Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
 
-               info($this->l10n->t('Friend suggestion sent.'));
+               info($this->t('Friend suggestion sent.'));
        }
 
-       public function content(): string
+       protected function content(array $request = []): string
        {
                $cid = intval($this->parameters['contact']);
 
                $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
                if (empty($contact)) {
-                       notice($this->l10n->t('Contact not found.'));
+                       notice($this->t('Contact not found.'));
                        $this->baseUrl->redirect();
                }
 
@@ -134,15 +133,15 @@ class FriendSuggest extends BaseModule
                $tpl = Renderer::getMarkupTemplate('fsuggest.tpl');
                return Renderer::replaceMacros($tpl, [
                        '$contact_id'      => $cid,
-                       '$fsuggest_title'  => $this->l10n->t('Suggest Friends'),
+                       '$fsuggest_title'  => $this->t('Suggest Friends'),
                        '$fsuggest_select' => [
                                'suggest',
-                               $this->l10n->t('Suggest a friend for %s', $contact['name']),
+                               $this->t('Suggest a friend for %s', $contact['name']),
                                '',
                                '',
                                $formattedContacts,
                        ],
-                       '$submit'          => $this->l10n->t('Submit'),
+                       '$submit'          => $this->t('Submit'),
                ]);
        }
 }