2020-01-05 22:50:33 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
2021-03-29 06:40:20 +00:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 14:45:36 +00:00
|
|
|
*
|
|
|
|
* @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/>.
|
|
|
|
*
|
|
|
|
*/
|
2020-01-05 22:50:33 +00:00
|
|
|
|
2021-10-18 20:12:49 +00:00
|
|
|
namespace Friendica\Contact\Introduction\Factory;
|
2020-01-05 22:50:33 +00:00
|
|
|
|
2021-10-18 20:12:49 +00:00
|
|
|
use Friendica\BaseFactory;
|
|
|
|
use Friendica\Contact\Introduction\Entity;
|
|
|
|
use Friendica\Capabilities\ICanCreateFromTableRow;
|
2021-10-18 20:49:25 +00:00
|
|
|
use Friendica\Util\DateTimeFormat;
|
|
|
|
use Friendica\Util\Strings;
|
2020-01-05 22:50:33 +00:00
|
|
|
|
2021-10-18 20:12:49 +00:00
|
|
|
class Introduction extends BaseFactory implements ICanCreateFromTableRow
|
2020-01-05 22:50:33 +00:00
|
|
|
{
|
2021-10-18 20:12:49 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function createFromTableRow(array $row): Entity\Introduction
|
|
|
|
{
|
|
|
|
return new Entity\Introduction(
|
2021-10-18 20:49:25 +00:00
|
|
|
$row['uid'] ?? 0,
|
|
|
|
$row['suggest-cid'] ?? 0,
|
|
|
|
$row['fid'] ?? null,
|
|
|
|
$row['contact-id'] ?? null,
|
2021-10-18 20:12:49 +00:00
|
|
|
!empty($row['knowyou']),
|
2021-10-18 20:49:25 +00:00
|
|
|
!empty($row['duplex']),
|
|
|
|
$row['note'] ?? '',
|
|
|
|
$row['hash'] ?? '',
|
|
|
|
new \DateTime($row['datetime'] ?? 'now', new \DateTimeZone('UTC')),
|
2021-10-18 20:12:49 +00:00
|
|
|
!empty($row['ignore']),
|
|
|
|
$row['id'] ?? null
|
|
|
|
);
|
|
|
|
}
|
2021-10-18 20:49:25 +00:00
|
|
|
|
|
|
|
public function createNew(
|
|
|
|
int $uid,
|
|
|
|
int $cid,
|
|
|
|
string $note,
|
|
|
|
int $fid = null,
|
|
|
|
int $sid = null,
|
|
|
|
bool $knowyou = false,
|
|
|
|
bool $duplex = false
|
|
|
|
): Entity\Introduction {
|
|
|
|
return $this->createFromTableRow([
|
|
|
|
'uid' => $uid,
|
|
|
|
'fid' => $fid,
|
|
|
|
'contact-id' => $cid,
|
|
|
|
'suggest-cid' => $sid,
|
|
|
|
'knowyou' => $knowyou,
|
|
|
|
'duplex' => $duplex,
|
|
|
|
'note' => $note,
|
|
|
|
'hash' => Strings::getRandomHex(),
|
|
|
|
'datetime' => DateTimeFormat::utcNow(),
|
|
|
|
'ignore' => false,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createDummy(int $id): Entity\Introduction
|
|
|
|
{
|
|
|
|
return $this->createFromTableRow(['id' => $id]);
|
|
|
|
}
|
2020-01-05 22:50:33 +00:00
|
|
|
}
|