]> git.mxchange.org Git - friendica.git/blob - src/Module/Profile/Index.php
Merge pull request #12655 from annando/fix-communication
[friendica.git] / src / Module / Profile / Index.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module\Profile;
23
24 use Friendica\App;
25 use Friendica\BaseModule;
26 use Friendica\Content\Conversation;
27 use Friendica\Core\Config\Capability\IManageConfigValues;
28 use Friendica\Core\L10n;
29 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
30 use Friendica\Core\Session\Capability\IHandleUserSessions;
31 use Friendica\Database\Database;
32 use Friendica\Module\Response;
33 use Friendica\Profile\ProfileField\Repository\ProfileField;
34 use Friendica\Util\DateTimeFormat;
35 use Friendica\Util\Profiler;
36 use Psr\Log\LoggerInterface;
37
38 /**
39  * Profile index router
40  *
41  * The default profile path (https://domain.tld/profile/nickname) has to serve the profile data when queried as an
42  * ActivityPub endpoint, but it should show statuses to web users.
43  *
44  * Both these view have dedicated sub-paths,
45  * respectively https://domain.tld/profile/nickname/profile and https://domain.tld/profile/nickname/conversations
46  */
47 class Index extends BaseModule
48 {
49         /** @var Database */
50         private $database;
51         /** @var App */
52         private $app;
53         /** @var IHandleUserSessions */
54         private $session;
55         /** @var IManageConfigValues */
56         private $config;
57         /** @var App\Page */
58         private $page;
59         /** @var ProfileField */
60         private $profileField;
61         /** @var DateTimeFormat */
62         private $dateTimeFormat;
63         /** @var Conversation */
64         private $conversation;
65         /** @var IManagePersonalConfigValues */
66         private $pConfig;
67         /** @var App\Mode */
68         private $mode;
69
70         public function __construct(App\Mode $mode, IManagePersonalConfigValues $pConfig, Conversation $conversation, DateTimeFormat $dateTimeFormat, ProfileField $profileField, App\Page $page, IManageConfigValues $config, IHandleUserSessions $session, App $app, Database $database, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
71         {
72                 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
73
74                 $this->database       = $database;
75                 $this->app            = $app;
76                 $this->session        = $session;
77                 $this->config         = $config;
78                 $this->page           = $page;
79                 $this->profileField   = $profileField;
80                 $this->dateTimeFormat = $dateTimeFormat;
81                 $this->conversation   = $conversation;
82                 $this->pConfig        = $pConfig;
83                 $this->mode           = $mode;
84         }
85
86         protected function rawContent(array $request = [])
87         {
88                 (new Profile($this->profileField, $this->page, $this->config, $this->session, $this->app, $this->database, $this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->rawContent();
89         }
90
91         protected function content(array $request = []): string
92         {
93                 return (new Conversations($this->mode, $this->pConfig, $this->conversation, $this->session, $this->config, $this->dateTimeFormat, $this->page, $this->app, $this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->content();
94         }
95 }