2021-10-08 13:45:20 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Profile\ProfileField\Factory;
|
|
|
|
|
|
|
|
use Friendica\BaseFactory;
|
|
|
|
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
|
|
|
use Friendica\Profile\ProfileField\Entity;
|
|
|
|
use Friendica\Capabilities\ICanCreateFromTableRow;
|
2021-10-10 14:39:35 -04:00
|
|
|
use Friendica\Security\PermissionSet\Entity\PermissionSet;
|
2021-10-08 13:45:20 -04:00
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
|
|
|
|
class ProfileField extends BaseFactory implements ICanCreateFromTableRow
|
|
|
|
{
|
|
|
|
/** @var PermissionSetDepository */
|
|
|
|
private $permissionSetDepository;
|
|
|
|
|
|
|
|
public function __construct(LoggerInterface $logger, PermissionSetDepository $permissionSetDepository)
|
|
|
|
{
|
|
|
|
parent::__construct($logger);
|
|
|
|
|
|
|
|
$this->permissionSetDepository = $permissionSetDepository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-10-10 14:39:35 -04:00
|
|
|
public function createFromTableRow(array $row, PermissionSet $permissionSet = null): Entity\ProfileField
|
2021-10-08 13:45:20 -04:00
|
|
|
{
|
|
|
|
return new Entity\ProfileField(
|
|
|
|
$this->permissionSetDepository,
|
|
|
|
$row['uid'],
|
|
|
|
$row['order'],
|
|
|
|
$row['psid'],
|
|
|
|
$row['label'],
|
|
|
|
$row['value'],
|
2021-10-10 14:39:35 -04:00
|
|
|
new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC')),
|
|
|
|
new \DateTime($row['edited'] ?? 'now', new \DateTimeZone('UTC')),
|
|
|
|
$row['id'],
|
|
|
|
$permissionSet
|
2021-10-08 13:45:20 -04:00
|
|
|
);
|
|
|
|
}
|
2021-10-10 14:39:35 -04:00
|
|
|
|
|
|
|
public function createFromString(
|
|
|
|
int $uid,
|
|
|
|
int $order,
|
|
|
|
string $label,
|
|
|
|
string $value,
|
|
|
|
PermissionSet $permissionSet
|
|
|
|
): Entity\ProfileField {
|
|
|
|
return $this->createFromTableRow([
|
|
|
|
'uid' => $uid,
|
|
|
|
'order' => $order,
|
|
|
|
'psid' => $permissionSet->id,
|
|
|
|
'label' => $label,
|
|
|
|
'value' => $value,
|
|
|
|
], $permissionSet);
|
|
|
|
}
|
2021-10-08 13:45:20 -04:00
|
|
|
}
|