]> git.mxchange.org Git - friendica.git/commitdiff
User Repository\UserDefinedChannel->selectByUid instead of Factory\UserDefinedChannel...
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 7 Oct 2023 09:44:24 +0000 (05:44 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 7 Oct 2023 09:48:23 +0000 (05:48 -0400)
- Rename Repository\Channel to Repository\UserDefinedChannel
- Add new Collection\UserDefinedChannels class
- Move Factory\Timeline->createFromTableRow to Factory\UserDefinedChannel

13 files changed:
src/Content/Conversation/Collection/UserDefinedChannels.php [new file with mode: 0644]
src/Content/Conversation/Factory/Timeline.php
src/Content/Conversation/Factory/UserDefinedChannel.php
src/Content/Conversation/Repository/Channel.php [deleted file]
src/Content/Conversation/Repository/UserDefinedChannel.php [new file with mode: 0644]
src/Content/Widget.php
src/DI.php
src/Module/Conversation/Channel.php
src/Module/Conversation/Community.php
src/Module/Conversation/Network.php
src/Module/Conversation/Timeline.php
src/Module/Settings/Channels.php
src/Module/Settings/Display.php

diff --git a/src/Content/Conversation/Collection/UserDefinedChannels.php b/src/Content/Conversation/Collection/UserDefinedChannels.php
new file mode 100644 (file)
index 0000000..5dc7326
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Content\Conversation\Collection;
+
+class UserDefinedChannels extends Timelines
+{
+}
index 804f6a3382cde306c7fd694eee48ba5d23a95bc9..a726762fd54388c9861ad560edd36463f06ca0b0 100644 (file)
@@ -23,21 +23,21 @@ namespace Friendica\Content\Conversation\Factory;
 
 use Friendica\Capabilities\ICanCreateFromTableRow;
 use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
-use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\L10n;
 use Psr\Log\LoggerInterface;
 
-class Timeline extends \Friendica\BaseFactory implements ICanCreateFromTableRow
+class Timeline extends \Friendica\BaseFactory
 {
        /** @var L10n */
        protected $l10n;
        /** @var IManageConfigValues The config */
        protected $config;
-       /** @var Channel */
+       /** @var UserDefinedChannel */
        protected $channelRepository;
 
-       public function __construct(Channel $channel, L10n $l10n, LoggerInterface $logger, IManageConfigValues $config)
+       public function __construct(UserDefinedChannel $channel, L10n $l10n, LoggerInterface $logger, IManageConfigValues $config)
        {
                parent::__construct($logger);
 
@@ -45,21 +45,4 @@ class Timeline extends \Friendica\BaseFactory implements ICanCreateFromTableRow
                $this->l10n              = $l10n;
                $this->config            = $config;
        }
-
-       public function createFromTableRow(array $row): TimelineEntity
-       {
-               return new TimelineEntity(
-                       $row['id'] ?? null,
-                       $row['label'],
-                       $row['description'] ?? null,
-                       $row['access-key'] ?? null,
-                       null,
-                       $row['uid'],
-                       $row['include-tags'] ?? null,
-                       $row['exclude-tags'] ?? null,
-                       $row['full-text-search'] ?? null,
-                       $row['media-type'] ?? null,
-                       $row['circle'] ?? null,
-               );
-       }
 }
index 1b067d08b03a04b8f2894006129f76d9bbb77064..12816126dbe12b24ffd23902d51cfa957753737c 100644 (file)
 
 namespace Friendica\Content\Conversation\Factory;
 
+use Friendica\Capabilities\ICanCreateFromTableRow;
 use Friendica\Content\Conversation\Collection\Timelines;
+use Friendica\Content\Conversation\Entity;
 
-final class UserDefinedChannel extends Timeline
+final class UserDefinedChannel extends Timeline implements ICanCreateFromTableRow
 {
-       /**
-        * List of available user defined channels
-        *
-        * @param integer $uid
-        * @return Timelines
-        */
-       public function getForUser(int $uid): Timelines
+       public function isTimeline(string $selectedTab, int $uid): bool
        {
-               $tabs = [];
-               foreach ($this->channelRepository->selectByUid($uid) as $channel) {
-                       $tabs[] = $channel;
-               }
-
-               return new Timelines($tabs);
+               return is_numeric($selectedTab) && $uid && $this->channelRepository->existsById($selectedTab, $uid);
        }
 
-       public function isTimeline(string $selectedTab, int $uid): bool
+       public function createFromTableRow(array $row): Entity\UserDefinedChannel
        {
-               return is_numeric($selectedTab) && $uid && $this->channelRepository->existsById($selectedTab, $uid);
+               return new Entity\UserDefinedChannel(
+                       $row['id'] ?? null,
+                       $row['label'],
+                       $row['description'] ?? null,
+                       $row['access-key'] ?? null,
+                       null,
+                       $row['uid'],
+                       $row['include-tags'] ?? null,
+                       $row['exclude-tags'] ?? null,
+                       $row['full-text-search'] ?? null,
+                       $row['media-type'] ?? null,
+                       $row['circle'] ?? null,
+               );
        }
 }
diff --git a/src/Content/Conversation/Repository/Channel.php b/src/Content/Conversation/Repository/Channel.php
deleted file mode 100644 (file)
index 19fac3b..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-/**
- * @copyright Copyright (C) 2010-2023, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Content\Conversation\Repository;
-
-use Friendica\BaseCollection;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
-use Friendica\Content\Conversation\Entity\UserDefinedChannel;
-use Friendica\Content\Conversation\Factory\Timeline;
-use Friendica\Database\Database;
-use Psr\Log\LoggerInterface;
-
-class Channel extends \Friendica\BaseRepository
-{
-       protected static $table_name = 'channel';
-
-       public function __construct(Database $database, LoggerInterface $logger, Timeline $factory)
-       {
-               parent::__construct($database, $logger, $factory);
-       }
-
-       /**
-        * Fetch a single user channel
-        *
-        * @param int $id  The id of the user defined channel
-        * @param int $uid The user that this channel belongs to. (Not part of the primary key)
-        * @return TimelineEntity
-        * @throws \Friendica\Network\HTTPException\NotFoundException
-        */
-       public function selectById(int $id, int $uid): TimelineEntity
-       {
-               return $this->_selectOne(['id' => $id, 'uid' => $uid]);
-       }
-
-       /**
-        * Checks if the provided channel id exists for this user
-        *
-        * @param integer $id
-        * @param integer $uid
-        * @return boolean
-        */
-       public function existsById(int $id, int $uid): bool
-       {
-               return $this->exists(['id' => $id, 'uid' => $uid]);
-       }
-
-       /**
-        * Delete the given channel
-        *
-        * @param integer $id
-        * @param integer $uid
-        * @return boolean
-        */
-       public function deleteById(int $id, int $uid): bool
-       {
-               return $this->db->delete('channel', ['id' => $id, 'uid' => $uid]);
-       }
-
-       /**
-        * Fetch all user channels
-        *
-        * @param integer $uid
-        * @return BaseCollection
-        */
-       public function selectByUid(int $uid): BaseCollection
-       {
-               return $this->_select(['uid' => $uid]);
-       }
-
-       public function save(UserDefinedChannel $Channel): UserDefinedChannel
-       {
-               $fields = [
-                       'label'            => $Channel->label,
-                       'description'      => $Channel->description,
-                       'access-key'       => $Channel->accessKey,
-                       'uid'              => $Channel->uid,
-                       'circle'           => $Channel->circle,
-                       'include-tags'     => $Channel->includeTags,
-                       'exclude-tags'     => $Channel->excludeTags,
-                       'full-text-search' => $Channel->fullTextSearch,
-                       'media-type'       => $Channel->mediaType,
-               ];
-
-               if ($Channel->code) {
-                       $this->db->update(self::$table_name, $fields, ['uid' => $Channel->uid, 'id' => $Channel->code]);
-               } else {
-                       $this->db->insert(self::$table_name, $fields, Database::INSERT_IGNORE);
-
-                       $newChannelId = $this->db->lastInsertId();
-
-                       $Channel = $this->selectById($newChannelId, $Channel->uid);
-               }
-
-               return $Channel;
-       }
-}
diff --git a/src/Content/Conversation/Repository/UserDefinedChannel.php b/src/Content/Conversation/Repository/UserDefinedChannel.php
new file mode 100644 (file)
index 0000000..1014711
--- /dev/null
@@ -0,0 +1,133 @@
+<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Content\Conversation\Repository;
+
+use Friendica\BaseCollection;
+use Friendica\Content\Conversation\Collection\UserDefinedChannels;
+use Friendica\Content\Conversation\Entity;
+use Friendica\Content\Conversation\Factory;
+use Friendica\Database\Database;
+use Psr\Log\LoggerInterface;
+
+class UserDefinedChannel extends \Friendica\BaseRepository
+{
+       protected static $table_name = 'channel';
+
+       public function __construct(Database $database, LoggerInterface $logger, Factory\UserDefinedChannel $factory)
+       {
+               parent::__construct($database, $logger, $factory);
+       }
+
+       /**
+        * @param array $condition
+        * @param array $params
+        * @return UserDefinedChannels
+        * @throws \Exception
+        */
+       protected function _select(array $condition, array $params = []): BaseCollection
+       {
+               $rows = $this->db->selectToArray(static::$table_name, [], $condition, $params);
+
+               $Entities = new UserDefinedChannels();
+               foreach ($rows as $fields) {
+                       $Entities[] = $this->factory->createFromTableRow($fields);
+               }
+
+               return $Entities;
+       }
+
+       /**
+        * Fetch a single user channel
+        *
+        * @param int $id  The id of the user defined channel
+        * @param int $uid The user that this channel belongs to. (Not part of the primary key)
+        * @return Entity\UserDefinedChannel
+        * @throws \Friendica\Network\HTTPException\NotFoundException
+        */
+       public function selectById(int $id, int $uid): Entity\UserDefinedChannel
+       {
+               return $this->_selectOne(['id' => $id, 'uid' => $uid]);
+       }
+
+       /**
+        * Checks if the provided channel id exists for this user
+        *
+        * @param integer $id
+        * @param integer $uid
+        * @return boolean
+        */
+       public function existsById(int $id, int $uid): bool
+       {
+               return $this->exists(['id' => $id, 'uid' => $uid]);
+       }
+
+       /**
+        * Delete the given channel
+        *
+        * @param integer $id
+        * @param integer $uid
+        * @return boolean
+        */
+       public function deleteById(int $id, int $uid): bool
+       {
+               return $this->db->delete('channel', ['id' => $id, 'uid' => $uid]);
+       }
+
+       /**
+        * Fetch all user channels
+        *
+        * @param integer $uid
+        * @return UserDefinedChannels
+        * @throws \Exception
+        */
+       public function selectByUid(int $uid): UserDefinedChannels
+       {
+               return $this->_select(['uid' => $uid]);
+       }
+
+       public function save(Entity\UserDefinedChannel $Channel): Entity\UserDefinedChannel
+       {
+               $fields = [
+                       'label'            => $Channel->label,
+                       'description'      => $Channel->description,
+                       'access-key'       => $Channel->accessKey,
+                       'uid'              => $Channel->uid,
+                       'circle'           => $Channel->circle,
+                       'include-tags'     => $Channel->includeTags,
+                       'exclude-tags'     => $Channel->excludeTags,
+                       'full-text-search' => $Channel->fullTextSearch,
+                       'media-type'       => $Channel->mediaType,
+               ];
+
+               if ($Channel->code) {
+                       $this->db->update(self::$table_name, $fields, ['uid' => $Channel->uid, 'id' => $Channel->code]);
+               } else {
+                       $this->db->insert(self::$table_name, $fields, Database::INSERT_IGNORE);
+
+                       $newChannelId = $this->db->lastInsertId();
+
+                       $Channel = $this->selectById($newChannelId, $Channel->uid);
+               }
+
+               return $Channel;
+       }
+}
index 876fbc79e489eafa8f0bd91d7e1e9918c7e1bff0..3147e99a5674ddcd52ac9de41451d5ccd8b2513d 100644 (file)
@@ -574,7 +574,7 @@ class Widget
                        }
                }
 
-               foreach (DI::UserDefinedChannelFactory()->getForUser($uid) as $channel) {
+               foreach (DI::userDefinedChannel()->selectByUid($uid) as $channel) {
                        if (empty($enabled) || in_array($channel->code, $enabled)) {
                                $channels[] = ['ref' => $channel->code, 'name' => $channel->label];
                        }
index 0cb194ef404d143c5ef15a086419eaef7b6fc6bf..4205640cc1efb2541919cd5a2ec7b307b444d55d 100644 (file)
@@ -571,12 +571,9 @@ abstract class DI
                return self::$dice->create(Content\Conversation\Factory\Channel::class);
        }
 
-       /**
-        * @return Content\Conversation\Factory\UserDefinedChannel
-        */
-       public static function UserDefinedChannelFactory()
+       public static function userDefinedChannel(): Content\Conversation\Repository\UserDefinedChannel
        {
-               return self::$dice->create(Content\Conversation\Factory\UserDefinedChannel::class);
+               return self::$dice->create(Content\Conversation\Repository\UserDefinedChannel::class);
        }
 
        /**
index dab17c4e199d9f10a376fde59d33faab1671bc87..171236e96671a9f0dbe35185669797ade0c47b84 100644 (file)
@@ -28,7 +28,7 @@ use Friendica\Content\Conversation;
 use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
 use Friendica\Content\Conversation\Factory\UserDefinedChannel as UserDefinedChannelFactory;
 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
-use Friendica\Content\Conversation\Repository\Channel as ChannelRepository;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel as ChannelRepository;
 use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
 use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
 use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
@@ -105,7 +105,7 @@ class Channel extends Timeline
 
                if (empty($request['mode']) || ($request['mode'] != 'raw')) {
                        $tabs = $this->getTabArray($this->channel->getTimelines($this->session->getLocalUserId()), 'channel');
-                       $tabs = array_merge($tabs, $this->getTabArray($this->userDefinedChannel->getForUser($this->session->getLocalUserId()), 'channel'));
+                       $tabs = array_merge($tabs, $this->getTabArray($this->channelRepository->selectByUid($this->session->getLocalUserId()), 'channel'));
                        $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel'));
 
                        $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
index 89af00043f928315ce5806ae9c89204b239f66ac..d0e3fb87022211c0bb6d434ee960ceac824f415f 100644 (file)
@@ -28,7 +28,7 @@ use Friendica\Content\BoundariesPager;
 use Friendica\Content\Conversation;
 use Friendica\Content\Conversation\Entity\Community as CommunityEntity;
 use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
-use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
 use Friendica\Content\Text\HTML;
@@ -70,7 +70,7 @@ class Community extends Timeline
        /** @var SystemMessages */
        protected $systemMessages;
 
-       public function __construct(Channel $channel, CommunityFactory $community, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(UserDefinedChannel $channel, CommunityFactory $community, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($channel, $mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
index 40f7d1239e51c41e57a293499cd60c40bab0b476..24e3e578913a8a83b262e93b6bf85b79ecefb74b 100644 (file)
@@ -27,7 +27,7 @@ use Friendica\Content\BoundariesPager;
 use Friendica\Content\Conversation;
 use Friendica\Content\Conversation\Entity\Network as NetworkEntity;
 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
-use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
 use Friendica\Content\Conversation\Factory\UserDefinedChannel as UserDefinedChannelFactory;
 use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
@@ -109,7 +109,7 @@ class Network extends Timeline
        /** @var NetworkFactory */
        protected $networkFactory;
 
-       public function __construct(UserDefinedChannelFactory $userDefinedChannel, NetworkFactory $network, CommunityFactory $community, ChannelFactory $channelFactory, Channel $channel, App $app, TimelineFactory $timeline, SystemMessages $systemMessages, Mode $mode, Conversation $conversation, App\Page $page, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(UserDefinedChannelFactory $userDefinedChannel, NetworkFactory $network, CommunityFactory $community, ChannelFactory $channelFactory, UserDefinedChannel $channel, App $app, TimelineFactory $timeline, SystemMessages $systemMessages, Mode $mode, Conversation $conversation, App\Page $page, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($channel, $mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
@@ -287,7 +287,7 @@ class Network extends Timeline
                $network_timelines = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'network_timelines', []);
                if (!empty($network_timelines)) {
                        $tabs = array_merge($tabs, $this->getTabArray($this->channel->getTimelines($this->session->getLocalUserId()), 'network', 'channel'));
-                       $tabs = array_merge($tabs, $this->getTabArray($this->userDefinedChannel->getForUser($this->session->getLocalUserId()), 'network', 'channel'));
+                       $tabs = array_merge($tabs, $this->getTabArray($this->channelRepository->selectByUid($this->session->getLocalUserId()), 'network', 'channel'));
                        $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'network', 'channel'));
                }
 
index 8ddba16c71961ae88fc069613b4ec9c561aaad3b..eb362eba7bb2812ad2bb740a0d6c8705f1008fa5 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\App\Mode;
 use Friendica\BaseModule;
 use Friendica\Content\Conversation\Collection\Timelines;
 use Friendica\Content\Conversation\Entity\Channel as ChannelEntity;
-use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Core\Cache\Capability\ICanCache;
 use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Config\Capability\IManageConfigValues;
@@ -80,10 +80,10 @@ class Timeline extends BaseModule
        protected $config;
        /** @var ICanCache */
        protected $cache;
-       /** @var Channel */
+       /** @var UserDefinedChannel */
        protected $channelRepository;
 
-       public function __construct(Channel $channel, Mode $mode, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(UserDefinedChannel $channel, Mode $mode, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, 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);
 
index 39d83a7e00a004f98d4ce68d1c6e4e46c241a4e5..55938e06f9119777c4e1c35e3c7c90ba0f451362 100644 (file)
@@ -22,8 +22,8 @@
 namespace Friendica\Module\Settings;
 
 use Friendica\App;
-use Friendica\Content\Conversation\Factory\Timeline;
-use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Factory;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
@@ -36,17 +36,17 @@ use Psr\Log\LoggerInterface;
 
 class Channels extends BaseSettings
 {
-       /** @var Channel */
+       /** @var UserDefinedChannel */
        private $channel;
-       /** @var Timeline */
-       private $timeline;
+       /** @var Factory\UserDefinedChannel */
+       private $userDefinedChannel;
 
-       public function __construct(Timeline $timeline, Channel $channel, App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(Factory\UserDefinedChannel $userDefinedChannel, UserDefinedChannel $channel, App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               $this->timeline = $timeline;
-               $this->channel  = $channel;
+               $this->userDefinedChannel = $userDefinedChannel;
+               $this->channel            = $channel;
        }
 
        protected function post(array $request = [])
@@ -63,7 +63,7 @@ class Channels extends BaseSettings
                self::checkFormSecurityTokenRedirectOnError('/settings/channels', 'settings_channels');
 
                if (!empty($request['add_channel'])) {
-                       $channel = $this->timeline->createFromTableRow([
+                       $channel = $this->userDefinedChannel->createFromTableRow([
                                'label'            => $request['new_label'],
                                'description'      => $request['new_description'],
                                'access-key'       => substr(mb_strtolower($request['new_access_key']), 0, 1),
@@ -86,7 +86,7 @@ class Channels extends BaseSettings
                                continue;
                        }
 
-                       $channel = $this->timeline->createFromTableRow([
+                       $channel = $this->userDefinedChannel->createFromTableRow([
                                'id'               => $id,
                                'label'            => $request['label'][$id],
                                'description'      => $request['description'][$id],
index 68ac500212028083521bec817570b5b0b05260c5..b5dbf01eb810161a3e9022c8eca2cdaf369a22be 100644 (file)
@@ -28,7 +28,7 @@ use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
 use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
 use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
 use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
-use Friendica\Content\Conversation\Factory\UserDefinedChannel as UserDefinedChannelFactory;
+use Friendica\Content\Conversation\Repository;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
@@ -59,7 +59,7 @@ class Display extends BaseSettings
        private $systemMessages;
        /** @var ChannelFactory */
        protected $channel;
-       /** @var UserDefinedChannelFactory */
+       /** @var Repository\UserDefinedChannel */
        protected $userDefinedChannel;
        /** @var CommunityFactory */
        protected $community;
@@ -68,7 +68,7 @@ class Display extends BaseSettings
        /** @var TimelineFactory */
        protected $timeline;
 
-       public function __construct(UserDefinedChannelFactory $userDefinedChannel, NetworkFactory $network, CommunityFactory $community, ChannelFactory $channel, TimelineFactory $timeline, SystemMessages $systemMessages, App $app, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(Repository\UserDefinedChannel $userDefinedChannel, NetworkFactory $network, CommunityFactory $community, ChannelFactory $channel, TimelineFactory $timeline, SystemMessages $systemMessages, App $app, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
@@ -267,8 +267,8 @@ class Display extends BaseSettings
                        $timelines[] = [
                                'label'        => $timeline->label,
                                'description'  => $timeline->description,
-                               'enable'       => ["enable{$timeline->code}", '', in_array($timeline->code, $enabled_timelines)],
-                               'bookmark'     => ["bookmark{$timeline->code}", '', in_array($timeline->code, $bookmarked_timelines)],
+                               'enable'       => ["enable[{$timeline->code}]", '', in_array($timeline->code, $enabled_timelines)],
+                               'bookmark'     => ["bookmark[{$timeline->code}]", '', in_array($timeline->code, $bookmarked_timelines)],
                        ];
                }
 
@@ -357,7 +357,7 @@ class Display extends BaseSettings
                        $timelines[] = $channel;
                }
 
-               foreach ($this->userDefinedChannel->getForUser($uid) as $channel) {
+               foreach ($this->userDefinedChannel->selectByUid($uid) as $channel) {
                        $timelines[] = $channel;
                }