3 namespace Friendica\Security\PermissionSet\Factory;
5 use Friendica\BaseFactory;
6 use Friendica\Capabilities\ICanCreateFromTableRow;
7 use Friendica\Security\PermissionSet\Entity;
8 use Friendica\Util\ACLFormatter;
9 use Psr\Log\LoggerInterface;
11 class PermissionSet extends BaseFactory implements ICanCreateFromTableRow
13 /** @var ACLFormatter */
16 public function __construct(LoggerInterface $logger, ACLFormatter $formatter)
18 parent::__construct($logger);
20 $this->formatter = $formatter;
26 public function createFromTableRow(array $row): Entity\PermissionSet
28 return new Entity\PermissionSet(
30 $this->formatter->expand($row['allow_cid'] ?? ''),
31 $this->formatter->expand($row['allow_gid'] ?? ''),
32 $this->formatter->expand($row['deny_cid'] ?? ''),
33 $this->formatter->expand($row['deny_gid'] ?? ''),
39 * Creates a new PermissionSet based on it's fields
42 * @param string $allow_cid
43 * @param string $allow_gid
44 * @param string $deny_cid
45 * @param string $deny_gid
47 * @return Entity\PermissionSet
49 public function createFromString(
51 string $allow_cid = '',
52 string $allow_gid = '',
53 string $deny_cid = '',
54 string $deny_gid = '',
55 int $id = null): Entity\PermissionSet
57 return $this->createFromTableRow([
59 'allow_cid' => $allow_cid,
60 'allow_gid' => $allow_gid,
61 'deny_cid' => $deny_cid,
62 'deny_gid' => $deny_gid,