mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-12 00:04:27 +02:00
User Repository\UserDefinedChannel->selectByUid instead of Factory\UserDefinedChannel->getForUser
- Rename Repository\Channel to Repository\UserDefinedChannel - Add new Collection\UserDefinedChannels class - Move Factory\Timeline->createFromTableRow to Factory\UserDefinedChannel
This commit is contained in:
parent
8ac6d0ef04
commit
710f9eecb2
12 changed files with 108 additions and 80 deletions
|
@ -22,30 +22,48 @@
|
|||
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\Content\Conversation\Collection\UserDefinedChannels;
|
||||
use Friendica\Content\Conversation\Entity;
|
||||
use Friendica\Content\Conversation\Factory;
|
||||
use Friendica\Database\Database;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Channel extends \Friendica\BaseRepository
|
||||
class UserDefinedChannel extends \Friendica\BaseRepository
|
||||
{
|
||||
protected static $table_name = 'channel';
|
||||
|
||||
public function __construct(Database $database, LoggerInterface $logger, Timeline $factory)
|
||||
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 TimelineEntity
|
||||
* @return Entity\UserDefinedChannel
|
||||
* @throws \Friendica\Network\HTTPException\NotFoundException
|
||||
*/
|
||||
public function selectById(int $id, int $uid): TimelineEntity
|
||||
public function selectById(int $id, int $uid): Entity\UserDefinedChannel
|
||||
{
|
||||
return $this->_selectOne(['id' => $id, 'uid' => $uid]);
|
||||
}
|
||||
|
@ -78,14 +96,15 @@ class Channel extends \Friendica\BaseRepository
|
|||
* Fetch all user channels
|
||||
*
|
||||
* @param integer $uid
|
||||
* @return BaseCollection
|
||||
* @return UserDefinedChannels
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function selectByUid(int $uid): BaseCollection
|
||||
public function selectByUid(int $uid): UserDefinedChannels
|
||||
{
|
||||
return $this->_select(['uid' => $uid]);
|
||||
}
|
||||
|
||||
public function save(UserDefinedChannel $Channel): UserDefinedChannel
|
||||
public function save(Entity\UserDefinedChannel $Channel): Entity\UserDefinedChannel
|
||||
{
|
||||
$fields = [
|
||||
'label' => $Channel->label,
|
Loading…
Add table
Add a link
Reference in a new issue