From: Michael Date: Tue, 5 Sep 2023 05:15:14 +0000 (+0000) Subject: Model class moved to factory X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6b131a3985c89bc0c7274f0f7ebd0be0c8d8cfa4;p=friendica.git Model class moved to factory --- diff --git a/src/Content/Conversation/Factory/Channel.php b/src/Content/Conversation/Factory/Channel.php new file mode 100644 index 0000000000..f95971d647 --- /dev/null +++ b/src/Content/Conversation/Factory/Channel.php @@ -0,0 +1,64 @@ +. + * + */ + + namespace Friendica\Content\Conversation\Factory; + +use Friendica\Model\User; +use Friendica\Content\Conversation\Entity\Channel as ChannelEntity; +use Friendica\Core\L10n; +use Friendica\Database\Database; +use Psr\Log\LoggerInterface; + +final class Channel extends \Friendica\BaseModel +{ + /** @var L10n */ + protected $l10n; + + public function __construct(L10n $l10n, Database $database, LoggerInterface $logger, array $data = []) + { + parent::__construct($database, $logger, $data); + + $this->l10n = $l10n; + } + + /** + * List of available channels + * + * @param integer $uid + * @return array + */ + public function getForUser(int $uid): array + { + $language = User::getLanguageCode($uid); + $languages = $this->l10n->getAvailableLanguages(true); + + $tabs = [ + new ChannelEntity(ChannelEntity::FORYOU, $this->l10n->t('For you'), $this->l10n->t('Posts from contacts you interact with and who interact with you'), 'y'), + new ChannelEntity(ChannelEntity::WHATSHOT, $this->l10n->t('What\'s Hot'), $this->l10n->t('Posts with a lot of interactions'), 'h'), + new ChannelEntity(ChannelEntity::LANGUAGE, $languages[$language], $this->l10n->t('Posts in %s', $languages[$language]), 'g'), + new ChannelEntity(ChannelEntity::FOLLOWERS, $this->l10n->t('Followers'), $this->l10n->t('Posts from your followers that you don\'t follow'), 'f'), + new ChannelEntity(ChannelEntity::IMAGE, $this->l10n->t('Images'), $this->l10n->t('Posts with images'), 'i'), + new ChannelEntity(ChannelEntity::AUDIO, $this->l10n->t('Audio'), $this->l10n->t('Posts with audio'), 'd'), + new ChannelEntity(ChannelEntity::VIDEO, $this->l10n->t('Videos'), $this->l10n->t('Posts with videos'), 'v'), + ]; + return $tabs; + } +} diff --git a/src/Model/Channel.php b/src/Model/Channel.php deleted file mode 100644 index d6d4eaa55c..0000000000 --- a/src/Model/Channel.php +++ /dev/null @@ -1,64 +0,0 @@ -. - * - */ - - namespace Friendica\Model; - -use Friendica\Model\User; -use Friendica\Content\Conversation\Entity\Channel as ChannelEntity; -use Friendica\Core\L10n; -use Friendica\Database\Database; -use Psr\Log\LoggerInterface; - -final class Channel extends \Friendica\BaseModel -{ - /** @var L10n */ - protected $l10n; - - public function __construct(L10n $l10n, Database $database, LoggerInterface $logger, array $data = []) - { - parent::__construct($database, $logger, $data); - - $this->l10n = $l10n; - } - - /** - * List of available channels - * - * @param integer $uid - * @return array - */ - public function getForUser(int $uid): array - { - $language = User::getLanguageCode($uid); - $languages = $this->l10n->getAvailableLanguages(true); - - $tabs = [ - new ChannelEntity(ChannelEntity::FORYOU, $this->l10n->t('For you'), $this->l10n->t('Posts from contacts you interact with and who interact with you'), 'y'), - new ChannelEntity(ChannelEntity::WHATSHOT, $this->l10n->t('What\'s Hot'), $this->l10n->t('Posts with a lot of interactions'), 'h'), - new ChannelEntity(ChannelEntity::LANGUAGE, $languages[$language], $this->l10n->t('Posts in %s', $languages[$language]), 'g'), - new ChannelEntity(ChannelEntity::FOLLOWERS, $this->l10n->t('Followers'), $this->l10n->t('Posts from your followers that you don\'t follow'), 'f'), - new ChannelEntity(ChannelEntity::IMAGE, $this->l10n->t('Images'), $this->l10n->t('Posts with images'), 'i'), - new ChannelEntity(ChannelEntity::AUDIO, $this->l10n->t('Audio'), $this->l10n->t('Posts with audio'), 'd'), - new ChannelEntity(ChannelEntity::VIDEO, $this->l10n->t('Videos'), $this->l10n->t('Posts with videos'), 'v'), - ]; - return $tabs; - } -} diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index 3b85f7fb94..41eff2999c 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -27,6 +27,7 @@ use Friendica\BaseModule; use Friendica\Content\BoundariesPager; use Friendica\Content\Conversation; use Friendica\Content\Conversation\Entity\Channel as ChannelEntity; +use Friendica\Content\Conversation\Factory\Channel as ChannelFactory; use Friendica\Content\Feature; use Friendica\Content\Nav; use Friendica\Content\Text\HTML; @@ -46,7 +47,6 @@ use Friendica\Module\Security\Login; use Friendica\Network\HTTPException; use Friendica\Core\Session\Model\UserSession; use Friendica\Database\Database; -use Friendica\Model\Channel as ChannelModel; use Friendica\Model\Item; use Friendica\Module\Response; use Friendica\Navigation\SystemMessages; @@ -81,11 +81,11 @@ class Channel extends BaseModule protected $pConfig; /** @var Database */ protected $database; - /** @var ChannelModel */ + /** @var ChannelFactory */ protected $channel; - public function __construct(ChannelModel $channel, SystemMessages $systemMessages, Database $database, IManagePersonalConfigValues $pConfig, Mode $mode, Conversation $conversation, App\Page $page, IManageConfigValues $config, ICanCache $cache, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + public function __construct(ChannelFactory $channel, SystemMessages $systemMessages, Database $database, IManagePersonalConfigValues $pConfig, Mode $mode, Conversation $conversation, App\Page $page, IManageConfigValues $config, ICanCache $cache, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);