X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSecurity%2FPermissionSet%2FFactory%2FPermissionSet.php;h=2ef65d8ac8111f5c1916f795a946163ae9f8b1d6;hb=7e030720829036ab76eef4ab91f695710ce4bb11;hp=9887ffeb11a8f5ab8aaa47f4443bc84966517778;hpb=62eb16e9ad9adbd2fa712cccbb40ab53b8b16e5b;p=friendica.git diff --git a/src/Security/PermissionSet/Factory/PermissionSet.php b/src/Security/PermissionSet/Factory/PermissionSet.php index 9887ffeb11..2ef65d8ac8 100644 --- a/src/Security/PermissionSet/Factory/PermissionSet.php +++ b/src/Security/PermissionSet/Factory/PermissionSet.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\PermissionSet\Factory; @@ -20,39 +39,47 @@ class PermissionSet extends BaseFactory implements ICanCreateFromTableRow $this->formatter = $formatter; } + /** + * @inheritDoc + */ public function createFromTableRow(array $row): Entity\PermissionSet { return new Entity\PermissionSet( $row['uid'], - $this->formatter->expand($row['allow_cid'] ?? []), - $this->formatter->expand($row['allow_gid'] ?? []), - $this->formatter->expand($row['deny_cid'] ?? []), - $this->formatter->expand($row['deny_gid'] ?? []), + $this->formatter->expand($row['allow_cid'] ?? ''), + $this->formatter->expand($row['allow_gid'] ?? ''), + $this->formatter->expand($row['deny_cid'] ?? ''), + $this->formatter->expand($row['deny_gid'] ?? ''), $row['id'] ?? null ); } + /** + * Creates a new PermissionSet based on it's fields + * + * @param int $uid + * @param string $allow_cid + * @param string $allow_gid + * @param string $deny_cid + * @param string $deny_gid + * + * @return Entity\PermissionSet + */ public function createFromString( int $uid, string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', - string $deny_gid = '') + string $deny_gid = '', + int $id = null): Entity\PermissionSet { - return new Entity\PermissionSet( - $uid, - $this->formatter->expand($allow_cid), - $this->formatter->expand($allow_gid), - $this->formatter->expand($deny_cid), - $this->formatter->expand($deny_gid) - ); - } - - public function createPrototypeForUser(int $uid, string $allowCid): Entity\PermissionSet - { - return new Entity\PermissionSet( - $uid, - $this->formatter->expand($allowCid) - ); + return $this->createFromTableRow([ + 'uid' => $uid, + 'allow_cid' => $allow_cid, + 'allow_gid' => $allow_gid, + 'deny_cid' => $deny_cid, + 'deny_gid' => $deny_gid, + 'id' => $id, + ]); } }