mirror of
https://github.com/friendica/friendica
synced 2024-12-22 23:20:16 +00:00
Rename Depository to Repository
This commit is contained in:
parent
b407fbedc1
commit
5d92713a8e
17 changed files with 84 additions and 85 deletions
|
@ -10,7 +10,7 @@ use Friendica\Network\HTTPException\NotFoundException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Depositories are meant to store and retrieve Entities from the database.
|
* Repositories are meant to store and retrieve Entities from the database.
|
||||||
*
|
*
|
||||||
* The reason why there are methods prefixed with an underscore is because PHP doesn't support generic polymorphism
|
* The reason why there are methods prefixed with an underscore is because PHP doesn't support generic polymorphism
|
||||||
* which means we can't directly overload base methods and make parameters more strict (from a parent class to a child
|
* which means we can't directly overload base methods and make parameters more strict (from a parent class to a child
|
||||||
|
@ -19,7 +19,7 @@ use Psr\Log\LoggerInterface;
|
||||||
* Similarly, we can't make an overloaded method return type more strict until we only support PHP version 7.4 but this
|
* Similarly, we can't make an overloaded method return type more strict until we only support PHP version 7.4 but this
|
||||||
* is less pressing.
|
* is less pressing.
|
||||||
*/
|
*/
|
||||||
abstract class BaseDepository
|
abstract class BaseRepository
|
||||||
{
|
{
|
||||||
const LIMIT = 30;
|
const LIMIT = 30;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Contact\FriendSuggest\Depository;
|
namespace Friendica\Contact\FriendSuggest\Repository;
|
||||||
|
|
||||||
use Friendica\BaseCollection;
|
use Friendica\BaseRepository;
|
||||||
use Friendica\BaseDepository;
|
|
||||||
use Friendica\Contact\FriendSuggest\Collection;
|
use Friendica\Contact\FriendSuggest\Collection;
|
||||||
use Friendica\Contact\FriendSuggest\Entity;
|
use Friendica\Contact\FriendSuggest\Entity;
|
||||||
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException;
|
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException;
|
||||||
|
@ -13,7 +12,7 @@ use Friendica\Database\Database;
|
||||||
use Friendica\Network\HTTPException\NotFoundException;
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class FriendSuggest extends BaseDepository
|
class FriendSuggest extends BaseRepository
|
||||||
{
|
{
|
||||||
/** @var Factory\FriendSuggest */
|
/** @var Factory\FriendSuggest */
|
||||||
protected $factory;
|
protected $factory;
|
|
@ -19,9 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Contact\Introduction\Depository;
|
namespace Friendica\Contact\Introduction\Repository;
|
||||||
|
|
||||||
use Friendica\BaseDepository;
|
use Friendica\BaseRepository;
|
||||||
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
|
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
|
||||||
use Friendica\Contact\Introduction\Exception\IntroductionPersistenceException;
|
use Friendica\Contact\Introduction\Exception\IntroductionPersistenceException;
|
||||||
use Friendica\Contact\Introduction\Collection;
|
use Friendica\Contact\Introduction\Collection;
|
||||||
|
@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\NotFoundException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Introduction extends BaseDepository
|
class Introduction extends BaseRepository
|
||||||
{
|
{
|
||||||
/** @var Factory\Introduction */
|
/** @var Factory\Introduction */
|
||||||
protected $factory;
|
protected $factory;
|
|
@ -27,7 +27,7 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Worker\Delivery;
|
use Friendica\Worker\Delivery;
|
||||||
|
|
||||||
|
|
24
src/DI.php
24
src/DI.php
|
@ -427,11 +427,11 @@ abstract class DI
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Contact\FriendSuggest\Depository\FriendSuggest;
|
* @return Contact\FriendSuggest\Repository\FriendSuggest;
|
||||||
*/
|
*/
|
||||||
public static function fsuggest()
|
public static function fsuggest()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Contact\FriendSuggest\Depository\FriendSuggest::class);
|
return self::$dice->create(Contact\FriendSuggest\Repository\FriendSuggest::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -443,11 +443,11 @@ abstract class DI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Contact\Introduction\Depository\Introduction
|
* @return Contact\Introduction\Repository\Introduction
|
||||||
*/
|
*/
|
||||||
public static function intro()
|
public static function intro()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Contact\Introduction\Depository\Introduction::class);
|
return self::$dice->create(Contact\Introduction\Repository\Introduction::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,9 +458,9 @@ abstract class DI
|
||||||
return self::$dice->create(Contact\Introduction\Factory\Introduction::class);
|
return self::$dice->create(Contact\Introduction\Factory\Introduction::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function permissionSet(): Security\PermissionSet\Depository\PermissionSet
|
public static function permissionSet(): Security\PermissionSet\Repository\PermissionSet
|
||||||
{
|
{
|
||||||
return self::$dice->create(Security\PermissionSet\Depository\PermissionSet::class);
|
return self::$dice->create(Security\PermissionSet\Repository\PermissionSet::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function permissionSetFactory(): Security\PermissionSet\Factory\PermissionSet
|
public static function permissionSetFactory(): Security\PermissionSet\Factory\PermissionSet
|
||||||
|
@ -468,9 +468,9 @@ abstract class DI
|
||||||
return self::$dice->create(Security\PermissionSet\Factory\PermissionSet::class);
|
return self::$dice->create(Security\PermissionSet\Factory\PermissionSet::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function profileField(): Profile\ProfileField\Depository\ProfileField
|
public static function profileField(): Profile\ProfileField\Repository\ProfileField
|
||||||
{
|
{
|
||||||
return self::$dice->create(Profile\ProfileField\Depository\ProfileField::class);
|
return self::$dice->create(Profile\ProfileField\Repository\ProfileField::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function profileFieldFactory(): Profile\ProfileField\Factory\ProfileField
|
public static function profileFieldFactory(): Profile\ProfileField\Factory\ProfileField
|
||||||
|
@ -478,9 +478,9 @@ abstract class DI
|
||||||
return self::$dice->create(Profile\ProfileField\Factory\ProfileField::class);
|
return self::$dice->create(Profile\ProfileField\Factory\ProfileField::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function notification(): Navigation\Notifications\Depository\Notification
|
public static function notification(): Navigation\Notifications\Repository\Notification
|
||||||
{
|
{
|
||||||
return self::$dice->create(Navigation\Notifications\Depository\Notification::class);
|
return self::$dice->create(Navigation\Notifications\Repository\Notification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function notificationFactory(): Navigation\Notifications\Factory\Notification
|
public static function notificationFactory(): Navigation\Notifications\Factory\Notification
|
||||||
|
@ -488,9 +488,9 @@ abstract class DI
|
||||||
return self::$dice->create(Navigation\Notifications\Factory\Notification::class);
|
return self::$dice->create(Navigation\Notifications\Factory\Notification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function notify(): Navigation\Notifications\Depository\Notify
|
public static function notify(): Navigation\Notifications\Repository\Notify
|
||||||
{
|
{
|
||||||
return self::$dice->create(Navigation\Notifications\Depository\Notify::class);
|
return self::$dice->create(Navigation\Notifications\Repository\Notify::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function notifyFactory(): Navigation\Notifications\Factory\Notify
|
public static function notifyFactory(): Navigation\Notifications\Factory\Notify
|
||||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Collection\Api\Mastodon\Fields;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Profile\ProfileField\Depository\ProfileField as ProfileFieldDepository;
|
use Friendica\Profile\ProfileField\Repository\ProfileField as ProfileFieldRepository;
|
||||||
use ImagickException;
|
use ImagickException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@ class Account extends BaseFactory
|
||||||
{
|
{
|
||||||
/** @var BaseURL */
|
/** @var BaseURL */
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
/** @var ProfileFieldDepository */
|
/** @var ProfileFieldRepository */
|
||||||
private $profileFieldDepo;
|
private $profileFieldRepo;
|
||||||
/** @var Field */
|
/** @var Field */
|
||||||
private $mstdnFieldFactory;
|
private $mstdnFieldFactory;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, BaseURL $baseURL, ProfileFieldDepository $profileFieldDepo, Field $mstdnFieldFactory)
|
public function __construct(LoggerInterface $logger, BaseURL $baseURL, ProfileFieldRepository $profileFieldRepo, Field $mstdnFieldFactory)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
$this->baseUrl = $baseURL;
|
$this->baseUrl = $baseURL;
|
||||||
$this->profileFieldDepo = $profileFieldDepo;
|
$this->profileFieldRepo = $profileFieldRepo;
|
||||||
$this->mstdnFieldFactory = $mstdnFieldFactory;
|
$this->mstdnFieldFactory = $mstdnFieldFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Account extends BaseFactory
|
||||||
|
|
||||||
$self_contact = Contact::selectFirst(['uid'], ['nurl' => $publicContact['nurl'], 'self' => true]);
|
$self_contact = Contact::selectFirst(['uid'], ['nurl' => $publicContact['nurl'], 'self' => true]);
|
||||||
if (!empty($self_contact['uid'])) {
|
if (!empty($self_contact['uid'])) {
|
||||||
$profileFields = $this->profileFieldDepo->selectPublicFieldsByUserId($self_contact['uid']);
|
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($self_contact['uid']);
|
||||||
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
||||||
} else {
|
} else {
|
||||||
$fields = new Fields();
|
$fields = new Fields();
|
||||||
|
@ -94,7 +94,7 @@ class Account extends BaseFactory
|
||||||
{
|
{
|
||||||
$publicContact = Contact::selectFirst([], ['uid' => $userId, 'self' => true]);
|
$publicContact = Contact::selectFirst([], ['uid' => $userId, 'self' => true]);
|
||||||
|
|
||||||
$profileFields = $this->profileFieldDepo->selectPublicFieldsByUserId($userId);
|
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($userId);
|
||||||
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
||||||
|
|
||||||
$apContact = APContact::getByURL($publicContact['url'], false);
|
$apContact = APContact::getByURL($publicContact['url'], false);
|
||||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Module\BaseApi;
|
use Friendica\Module\BaseApi;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API endpoint: /api/friendica/profile/show
|
* API endpoint: /api/friendica/profile/show
|
||||||
|
|
|
@ -32,7 +32,7 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
use Friendica\Navigation\Notifications\Collection\FormattedNotifications;
|
use Friendica\Navigation\Notifications\Collection\FormattedNotifications;
|
||||||
use Friendica\Navigation\Notifications\Depository;
|
use Friendica\Navigation\Notifications\Repository;
|
||||||
use Friendica\Navigation\Notifications\ValueObject;
|
use Friendica\Navigation\Notifications\ValueObject;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
|
@ -54,14 +54,14 @@ class FormattedNotification extends BaseFactory
|
||||||
{
|
{
|
||||||
/** @var Database */
|
/** @var Database */
|
||||||
private $dba;
|
private $dba;
|
||||||
/** @var Depository\Notify */
|
/** @var Repository\Notify */
|
||||||
private $notify;
|
private $notify;
|
||||||
/** @var BaseURL */
|
/** @var BaseURL */
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
/** @var L10n */
|
/** @var L10n */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Database $dba, Depository\Notify $notify, BaseURL $baseUrl, L10n $l10n)
|
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notify, BaseURL $baseUrl, L10n $l10n)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Navigation\Notifications\Depository;
|
namespace Friendica\Navigation\Notifications\Repository;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Friendica\BaseCollection;
|
use Friendica\BaseCollection;
|
||||||
use Friendica\BaseDepository;
|
use Friendica\BaseRepository;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Verb;
|
use Friendica\Model\Verb;
|
||||||
|
@ -15,7 +15,7 @@ use Friendica\Network\HTTPException\NotFoundException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Notification extends BaseDepository
|
class Notification extends BaseRepository
|
||||||
{
|
{
|
||||||
/** @var Factory\Notification */
|
/** @var Factory\Notification */
|
||||||
protected $factory;
|
protected $factory;
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Navigation\Notifications\Depository;
|
namespace Friendica\Navigation\Notifications\Repository;
|
||||||
|
|
||||||
use Friendica\App\BaseURL;
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseDepository;
|
use Friendica\BaseRepository;
|
||||||
use Friendica\Content\Text\Plaintext;
|
use Friendica\Content\Text\Plaintext;
|
||||||
use Friendica\Core\Config\IConfig;
|
use Friendica\Core\Config\IConfig;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
|
@ -22,7 +22,7 @@ use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Emailer;
|
use Friendica\Util\Emailer;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Notify extends BaseDepository
|
class Notify extends BaseRepository
|
||||||
{
|
{
|
||||||
/** @var Factory\Notify */
|
/** @var Factory\Notify */
|
||||||
protected $factory;
|
protected $factory;
|
|
@ -19,9 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Profile\ProfileField\Depository;
|
namespace Friendica\Profile\ProfileField\Repository;
|
||||||
|
|
||||||
use Friendica\BaseDepository;
|
use Friendica\BaseRepository;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Profile\ProfileField\Exception\ProfileFieldNotFoundException;
|
use Friendica\Profile\ProfileField\Exception\ProfileFieldNotFoundException;
|
||||||
use Friendica\Profile\ProfileField\Exception\ProfileFieldPersistenceException;
|
use Friendica\Profile\ProfileField\Exception\ProfileFieldPersistenceException;
|
||||||
|
@ -29,11 +29,11 @@ use Friendica\Profile\ProfileField\Exception\UnexpectedPermissionSetException;
|
||||||
use Friendica\Profile\ProfileField\Factory;
|
use Friendica\Profile\ProfileField\Factory;
|
||||||
use Friendica\Profile\ProfileField\Entity;
|
use Friendica\Profile\ProfileField\Entity;
|
||||||
use Friendica\Profile\ProfileField\Collection;
|
use Friendica\Profile\ProfileField\Collection;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class ProfileField extends BaseDepository
|
class ProfileField extends BaseRepository
|
||||||
{
|
{
|
||||||
/** @var Factory\ProfileField */
|
/** @var Factory\ProfileField */
|
||||||
protected $factory;
|
protected $factory;
|
||||||
|
@ -42,14 +42,14 @@ class ProfileField extends BaseDepository
|
||||||
|
|
||||||
protected static $view_name = 'profile_field-view';
|
protected static $view_name = 'profile_field-view';
|
||||||
|
|
||||||
/** @var PermissionSetDepository */
|
/** @var PermissionSetRepository */
|
||||||
protected $permissionSetDepository;
|
protected $permissionSetRepository;
|
||||||
|
|
||||||
public function __construct(Database $database, LoggerInterface $logger, Factory\ProfileField $factory, PermissionSetDepository $permissionSetDepository)
|
public function __construct(Database $database, LoggerInterface $logger, Factory\ProfileField $factory, PermissionSetRepository $permissionSetRepository)
|
||||||
{
|
{
|
||||||
parent::__construct($database, $logger, $factory);
|
parent::__construct($database, $logger, $factory);
|
||||||
|
|
||||||
$this->permissionSetDepository = $permissionSetDepository;
|
$this->permissionSetRepository = $permissionSetRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +124,7 @@ class ProfileField extends BaseDepository
|
||||||
public function selectPublicFieldsByUserId(int $uid): Collection\ProfileFields
|
public function selectPublicFieldsByUserId(int $uid): Collection\ProfileFields
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$publicPermissionSet = $this->permissionSetDepository->selectPublicForUser($uid);
|
$publicPermissionSet = $this->permissionSetRepository->selectPublicForUser($uid);
|
||||||
|
|
||||||
return $this->select([
|
return $this->select([
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
|
@ -162,12 +162,12 @@ class ProfileField extends BaseDepository
|
||||||
*/
|
*/
|
||||||
public function selectByContactId(int $cid, int $uid): Collection\ProfileFields
|
public function selectByContactId(int $cid, int $uid): Collection\ProfileFields
|
||||||
{
|
{
|
||||||
$permissionSets = $this->permissionSetDepository->selectByContactId($cid, $uid);
|
$permissionSets = $this->permissionSetRepository->selectByContactId($cid, $uid);
|
||||||
|
|
||||||
$permissionSetIds = $permissionSets->column('id');
|
$permissionSetIds = $permissionSets->column('id');
|
||||||
|
|
||||||
// Includes public custom fields
|
// Includes public custom fields
|
||||||
$permissionSetIds[] = $this->permissionSetDepository->selectPublicForUser($uid)->id;
|
$permissionSetIds[] = $this->permissionSetRepository->selectPublicForUser($uid)->id;
|
||||||
|
|
||||||
return $this->select(
|
return $this->select(
|
||||||
['uid' => $uid, 'psid' => $permissionSetIds],
|
['uid' => $uid, 'psid' => $permissionSetIds],
|
|
@ -3,7 +3,7 @@
|
||||||
namespace Friendica\Security\PermissionSet\Entity;
|
namespace Friendica\Security\PermissionSet\Entity;
|
||||||
|
|
||||||
use Friendica\BaseEntity;
|
use Friendica\BaseEntity;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property-read int|null $id
|
* @property-read int|null $id
|
||||||
|
@ -55,7 +55,7 @@ class PermissionSet extends BaseEntity
|
||||||
*/
|
*/
|
||||||
public function isPublic(): bool
|
public function isPublic(): bool
|
||||||
{
|
{
|
||||||
return (($this->id === PermissionSetDepository::PUBLIC) ||
|
return (($this->id === PermissionSetRepository::PUBLIC) ||
|
||||||
(is_null($this->id) &&
|
(is_null($this->id) &&
|
||||||
empty($this->allow_cid) &&
|
empty($this->allow_cid) &&
|
||||||
empty($this->allow_gid) &&
|
empty($this->allow_gid) &&
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Security\PermissionSet\Depository;
|
namespace Friendica\Security\PermissionSet\Repository;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Friendica\BaseDepository;
|
use Friendica\BaseRepository;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
|
@ -33,7 +33,7 @@ use Friendica\Security\PermissionSet\Entity;
|
||||||
use Friendica\Util\ACLFormatter;
|
use Friendica\Util\ACLFormatter;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class PermissionSet extends BaseDepository
|
class PermissionSet extends BaseRepository
|
||||||
{
|
{
|
||||||
/** @var int Virtual permission set id for public permission */
|
/** @var int Virtual permission set id for public permission */
|
||||||
const PUBLIC = 0;
|
const PUBLIC = 0;
|
|
@ -6,7 +6,7 @@ use Friendica\Profile\ProfileField\Entity\ProfileField;
|
||||||
use Friendica\Profile\ProfileField\Exception\ProfileFieldNotFoundException;
|
use Friendica\Profile\ProfileField\Exception\ProfileFieldNotFoundException;
|
||||||
use Friendica\Profile\ProfileField\Exception\UnexpectedPermissionSetException;
|
use Friendica\Profile\ProfileField\Exception\UnexpectedPermissionSetException;
|
||||||
use Friendica\Profile\ProfileField\Factory\ProfileField as ProfileFieldFactory;
|
use Friendica\Profile\ProfileField\Factory\ProfileField as ProfileFieldFactory;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
|
||||||
use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory;
|
use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory;
|
||||||
use Friendica\Test\MockedTest;
|
use Friendica\Test\MockedTest;
|
||||||
use Friendica\Util\ACLFormatter;
|
use Friendica\Util\ACLFormatter;
|
||||||
|
@ -16,8 +16,8 @@ use Mockery\MockInterface;
|
||||||
|
|
||||||
class ProfileFieldTest extends MockedTest
|
class ProfileFieldTest extends MockedTest
|
||||||
{
|
{
|
||||||
/** @var MockInterface|PermissionSetDepository */
|
/** @var MockInterface|PermissionSetRepository */
|
||||||
protected $permissionSetDepository;
|
protected $permissionSetRepository;
|
||||||
/** @var ProfileFieldFactory */
|
/** @var ProfileFieldFactory */
|
||||||
protected $profileFieldFactory;
|
protected $profileFieldFactory;
|
||||||
/** @var MockInterface|PermissionSetFactory */
|
/** @var MockInterface|PermissionSetFactory */
|
||||||
|
@ -27,7 +27,7 @@ class ProfileFieldTest extends MockedTest
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->permissionSetDepository = \Mockery::mock(PermissionSetDepository::class);
|
$this->permissionSetRepository = \Mockery::mock(PermissionSetRepository::class);
|
||||||
$this->permissionSetFactory = new PermissionSetFactory(new VoidLogger(), new ACLFormatter());
|
$this->permissionSetFactory = new PermissionSetFactory(new VoidLogger(), new ACLFormatter());
|
||||||
$this->profileFieldFactory = new ProfileFieldFactory(new VoidLogger(), $this->permissionSetFactory);
|
$this->profileFieldFactory = new ProfileFieldFactory(new VoidLogger(), $this->permissionSetFactory);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ class ProfileFieldTest extends MockedTest
|
||||||
|
|
||||||
$permissionSet = $this->permissionSetFactory->createFromTableRow(['uid' => $uid, 'id' => $psid]);
|
$permissionSet = $this->permissionSetFactory->createFromTableRow(['uid' => $uid, 'id' => $psid]);
|
||||||
|
|
||||||
$this->permissionSetDepository->shouldReceive('selectOneById')->with($psid, $uid)->andReturns($permissionSet);
|
$this->permissionSetRepository->shouldReceive('selectOneById')->with($psid, $uid)->andReturns($permissionSet);
|
||||||
|
|
||||||
self::assertEquals($psid, $entity->permissionSet->id);
|
self::assertEquals($psid, $entity->permissionSet->id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Test\src\Profile\ProfileField\Depository;
|
namespace Friendica\Test\src\Profile\ProfileField\Repository;
|
||||||
|
|
||||||
use Friendica\Profile\ProfileField\Collection\ProfileFields;
|
use Friendica\Profile\ProfileField\Collection\ProfileFields;
|
||||||
use Friendica\Profile\ProfileField\Depository\ProfileField as ProfileFieldDepository;
|
use Friendica\Profile\ProfileField\Repository\ProfileField as ProfileFieldRepository;
|
||||||
use Friendica\Profile\ProfileField\Exception\ProfileFieldPersistenceException;
|
use Friendica\Profile\ProfileField\Exception\ProfileFieldPersistenceException;
|
||||||
use Friendica\Profile\ProfileField\Factory\ProfileField as ProfileFieldFactory;
|
use Friendica\Profile\ProfileField\Factory\ProfileField as ProfileFieldFactory;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet;
|
||||||
use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory;
|
use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
|
||||||
use Friendica\Test\FixtureTest;
|
use Friendica\Test\FixtureTest;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
class ProfileFieldTest extends FixtureTest
|
class ProfileFieldTest extends FixtureTest
|
||||||
{
|
{
|
||||||
/** @var ProfileFieldDepository */
|
/** @var ProfileFieldRepository */
|
||||||
private $depository;
|
private $depository;
|
||||||
/** @var ProfileFieldFactory */
|
/** @var ProfileFieldFactory */
|
||||||
private $factory;
|
private $factory;
|
||||||
/** @var PermissionSetFactory */
|
/** @var PermissionSetFactory */
|
||||||
private $permissionSetFactory;
|
private $permissionSetFactory;
|
||||||
/** @var PermissionSetDepository */
|
/** @var PermissionSetRepository */
|
||||||
private $permissionSetDepository;
|
private $permissionSetRepository;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ class ProfileFieldTest extends FixtureTest
|
||||||
$this->depository = DI::profileField();
|
$this->depository = DI::profileField();
|
||||||
$this->factory = DI::profileFieldFactory();
|
$this->factory = DI::profileFieldFactory();
|
||||||
$this->permissionSetFactory = DI::permissionSetFactory();
|
$this->permissionSetFactory = DI::permissionSetFactory();
|
||||||
$this->permissionSetDepository = DI::permissionSet();
|
$this->permissionSetRepository = DI::permissionSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ class ProfileFieldTest extends FixtureTest
|
||||||
*/
|
*/
|
||||||
public function testSaveNew()
|
public function testSaveNew()
|
||||||
{
|
{
|
||||||
$profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
|
$profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetRepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
|
||||||
|
|
||||||
self::assertEquals($profileField->uid, $profileField->permissionSet->uid);
|
self::assertEquals($profileField->uid, $profileField->permissionSet->uid);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class ProfileFieldTest extends FixtureTest
|
||||||
*/
|
*/
|
||||||
public function testUpdateOrder()
|
public function testUpdateOrder()
|
||||||
{
|
{
|
||||||
$profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
|
$profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetRepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
|
||||||
|
|
||||||
self::assertEquals($profileField->uid, $profileField->permissionSet->uid);
|
self::assertEquals($profileField->uid, $profileField->permissionSet->uid);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class ProfileFieldTest extends FixtureTest
|
||||||
*/
|
*/
|
||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
$profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
|
$profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetRepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
|
||||||
|
|
||||||
self::assertEquals($profileField->uid, $profileField->permissionSet->uid);
|
self::assertEquals($profileField->uid, $profileField->permissionSet->uid);
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ class ProfileFieldTest extends FixtureTest
|
||||||
|
|
||||||
self::assertEquals($savedProfileField, $selectedProfileField);
|
self::assertEquals($savedProfileField, $selectedProfileField);
|
||||||
|
|
||||||
$savedProfileField->update('another', 5, $this->permissionSetDepository->selectPublicForUser(42));
|
$savedProfileField->update('another', 5, $this->permissionSetRepository->selectPublicForUser(42));
|
||||||
self::assertEquals(PermissionSet::PUBLIC, $savedProfileField->permissionSet->id);
|
self::assertEquals(PermissionSet::PUBLIC, $savedProfileField->permissionSet->id);
|
||||||
|
|
||||||
$publicProfileField = $this->depository->save($savedProfileField);
|
$publicProfileField = $this->depository->save($savedProfileField);
|
||||||
|
|
||||||
self::assertEquals($this->permissionSetDepository->selectPublicForUser(42), $publicProfileField->permissionSet);
|
self::assertEquals($this->permissionSetRepository->selectPublicForUser(42), $publicProfileField->permissionSet);
|
||||||
self::assertEquals('another', $publicProfileField->value);
|
self::assertEquals('another', $publicProfileField->value);
|
||||||
self::assertEquals(5, $publicProfileField->order);
|
self::assertEquals(5, $publicProfileField->order);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Test\src\Security\PermissionSet\Depository;
|
namespace Friendica\Test\src\Security\PermissionSet\Repository;
|
||||||
|
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
|
||||||
use Friendica\Security\PermissionSet\Entity\PermissionSet;
|
use Friendica\Security\PermissionSet\Entity\PermissionSet;
|
||||||
use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory;
|
use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory;
|
||||||
use Friendica\Test\FixtureTest;
|
use Friendica\Test\FixtureTest;
|
||||||
|
@ -10,8 +10,8 @@ use Friendica\DI;
|
||||||
|
|
||||||
class PermissionSetTest extends FixtureTest
|
class PermissionSetTest extends FixtureTest
|
||||||
{
|
{
|
||||||
/** @var PermissionSetDepository */
|
/** @var PermissionSetRepository */
|
||||||
private $depository;
|
private $repository;
|
||||||
/** @var PermissionSetFactory */
|
/** @var PermissionSetFactory */
|
||||||
private $factory;
|
private $factory;
|
||||||
|
|
||||||
|
@ -19,20 +19,20 @@ class PermissionSetTest extends FixtureTest
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->depository = DI::permissionSet();
|
$this->repository = DI::permissionSet();
|
||||||
$this->factory = DI::permissionSetFactory();
|
$this->factory = DI::permissionSetFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectOneByIdPublic()
|
public function testSelectOneByIdPublic()
|
||||||
{
|
{
|
||||||
$permissionSet = $this->depository->selectPublicForUser(1);
|
$permissionSet = $this->repository->selectPublicForUser(1);
|
||||||
|
|
||||||
$this->assertInstanceOf(PermissionSet::class, $permissionSet);
|
$this->assertInstanceOf(PermissionSet::class, $permissionSet);
|
||||||
self::assertEmpty($permissionSet->allow_cid);
|
self::assertEmpty($permissionSet->allow_cid);
|
||||||
self::assertEmpty($permissionSet->allow_gid);
|
self::assertEmpty($permissionSet->allow_gid);
|
||||||
self::assertEmpty($permissionSet->deny_cid);
|
self::assertEmpty($permissionSet->deny_cid);
|
||||||
self::assertEmpty($permissionSet->deny_gid);
|
self::assertEmpty($permissionSet->deny_gid);
|
||||||
self::assertEmpty(PermissionSetDepository::PUBLIC, $permissionSet->id);
|
self::assertEmpty(PermissionSetRepository::PUBLIC, $permissionSet->id);
|
||||||
self::assertEquals(1, $permissionSet->uid);
|
self::assertEquals(1, $permissionSet->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,21 +43,21 @@ class PermissionSetTest extends FixtureTest
|
||||||
{
|
{
|
||||||
$permissionSet = $this->factory->createFromString(42, '', '<~>');
|
$permissionSet = $this->factory->createFromString(42, '', '<~>');
|
||||||
|
|
||||||
$permissionSet = $this->depository->selectOrCreate($permissionSet);
|
$permissionSet = $this->repository->selectOrCreate($permissionSet);
|
||||||
|
|
||||||
self::assertNotNull($permissionSet->id);
|
self::assertNotNull($permissionSet->id);
|
||||||
|
|
||||||
$permissionSetSelected = $this->depository->selectOneById($permissionSet->id, 42);
|
$permissionSetSelected = $this->repository->selectOneById($permissionSet->id, 42);
|
||||||
|
|
||||||
self::assertEquals($permissionSet, $permissionSetSelected);
|
self::assertEquals($permissionSet, $permissionSetSelected);
|
||||||
|
|
||||||
$newPermissionSet = $permissionSet->withAllowedContacts(['1', '2']);
|
$newPermissionSet = $permissionSet->withAllowedContacts(['1', '2']);
|
||||||
$savedPermissionSet = $this->depository->save($newPermissionSet);
|
$savedPermissionSet = $this->repository->save($newPermissionSet);
|
||||||
|
|
||||||
self::assertNotNull($savedPermissionSet->id);
|
self::assertNotNull($savedPermissionSet->id);
|
||||||
self::assertNull($newPermissionSet->id);
|
self::assertNull($newPermissionSet->id);
|
||||||
|
|
||||||
$permissionSetSavedSelected = $this->depository->selectOneById($savedPermissionSet->id, 42);
|
$permissionSetSavedSelected = $this->repository->selectOneById($savedPermissionSet->id, 42);
|
||||||
|
|
||||||
self::assertEquals($savedPermissionSet, $permissionSetSavedSelected);
|
self::assertEquals($savedPermissionSet, $permissionSetSavedSelected);
|
||||||
}
|
}
|
|
@ -55,7 +55,7 @@ use Friendica\Model\Photo;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Model\Storage;
|
use Friendica\Model\Storage;
|
||||||
use Friendica\Security\PermissionSet\Depository\PermissionSet;
|
use Friendica\Security\PermissionSet\Repository\PermissionSet;
|
||||||
use Friendica\Worker\Delivery;
|
use Friendica\Worker\Delivery;
|
||||||
|
|
||||||
// Post-update script of PR 5751
|
// Post-update script of PR 5751
|
||||||
|
|
Loading…
Reference in a new issue