1
0
Fork 0

Rename Depository to Repository

This commit is contained in:
Philipp Holzer 2021-10-21 23:18:08 +02:00 committed by Hypolite Petovan
parent b407fbedc1
commit 5d92713a8e
17 changed files with 84 additions and 85 deletions

View file

@ -10,7 +10,7 @@ use Friendica\Network\HTTPException\NotFoundException;
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
* 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
* is less pressing.
*/
abstract class BaseDepository
abstract class BaseRepository
{
const LIMIT = 30;

View file

@ -1,9 +1,8 @@
<?php
namespace Friendica\Contact\FriendSuggest\Depository;
namespace Friendica\Contact\FriendSuggest\Repository;
use Friendica\BaseCollection;
use Friendica\BaseDepository;
use Friendica\BaseRepository;
use Friendica\Contact\FriendSuggest\Collection;
use Friendica\Contact\FriendSuggest\Entity;
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException;
@ -13,7 +12,7 @@ use Friendica\Database\Database;
use Friendica\Network\HTTPException\NotFoundException;
use Psr\Log\LoggerInterface;
class FriendSuggest extends BaseDepository
class FriendSuggest extends BaseRepository
{
/** @var Factory\FriendSuggest */
protected $factory;

View file

@ -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\IntroductionPersistenceException;
use Friendica\Contact\Introduction\Collection;
@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Util\DateTimeFormat;
use Psr\Log\LoggerInterface;
class Introduction extends BaseDepository
class Introduction extends BaseRepository
{
/** @var Factory\Introduction */
protected $factory;

View file

@ -27,7 +27,7 @@ use Friendica\DI;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Object\Image;
use Friendica\Security\PermissionSet\Depository\PermissionSet;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
use Friendica\Util\Strings;
use Friendica\Worker\Delivery;

View file

@ -427,11 +427,11 @@ abstract class DI
//
/**
* @return Contact\FriendSuggest\Depository\FriendSuggest;
* @return Contact\FriendSuggest\Repository\FriendSuggest;
*/
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()
{
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);
}
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
@ -468,9 +468,9 @@ abstract class DI
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
@ -478,9 +478,9 @@ abstract class DI
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
@ -488,9 +488,9 @@ abstract class DI
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

View file

@ -27,7 +27,7 @@ use Friendica\Collection\Api\Mastodon\Fields;
use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Network\HTTPException;
use Friendica\Profile\ProfileField\Depository\ProfileField as ProfileFieldDepository;
use Friendica\Profile\ProfileField\Repository\ProfileField as ProfileFieldRepository;
use ImagickException;
use Psr\Log\LoggerInterface;
@ -35,17 +35,17 @@ class Account extends BaseFactory
{
/** @var BaseURL */
private $baseUrl;
/** @var ProfileFieldDepository */
private $profileFieldDepo;
/** @var ProfileFieldRepository */
private $profileFieldRepo;
/** @var Field */
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);
$this->baseUrl = $baseURL;
$this->profileFieldDepo = $profileFieldDepo;
$this->profileFieldRepo = $profileFieldRepo;
$this->mstdnFieldFactory = $mstdnFieldFactory;
}
@ -76,7 +76,7 @@ class Account extends BaseFactory
$self_contact = Contact::selectFirst(['uid'], ['nurl' => $publicContact['nurl'], 'self' => true]);
if (!empty($self_contact['uid'])) {
$profileFields = $this->profileFieldDepo->selectPublicFieldsByUserId($self_contact['uid']);
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($self_contact['uid']);
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
} else {
$fields = new Fields();
@ -94,7 +94,7 @@ class Account extends BaseFactory
{
$publicContact = Contact::selectFirst([], ['uid' => $userId, 'self' => true]);
$profileFields = $this->profileFieldDepo->selectPublicFieldsByUserId($userId);
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($userId);
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
$apContact = APContact::getByURL($publicContact['url'], false);

View file

@ -28,7 +28,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
use Friendica\Security\PermissionSet\Depository\PermissionSet;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
/**
* API endpoint: /api/friendica/profile/show

View file

@ -32,7 +32,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Post;
use Friendica\Module\BaseNotifications;
use Friendica\Navigation\Notifications\Collection\FormattedNotifications;
use Friendica\Navigation\Notifications\Depository;
use Friendica\Navigation\Notifications\Repository;
use Friendica\Navigation\Notifications\ValueObject;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Protocol\Activity;
@ -54,14 +54,14 @@ class FormattedNotification extends BaseFactory
{
/** @var Database */
private $dba;
/** @var Depository\Notify */
/** @var Repository\Notify */
private $notify;
/** @var BaseURL */
private $baseUrl;
/** @var 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);

View file

@ -1,10 +1,10 @@
<?php
namespace Friendica\Navigation\Notifications\Depository;
namespace Friendica\Navigation\Notifications\Repository;
use Exception;
use Friendica\BaseCollection;
use Friendica\BaseDepository;
use Friendica\BaseRepository;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Model\Verb;
@ -15,7 +15,7 @@ use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Util\DateTimeFormat;
use Psr\Log\LoggerInterface;
class Notification extends BaseDepository
class Notification extends BaseRepository
{
/** @var Factory\Notification */
protected $factory;

View file

@ -1,9 +1,9 @@
<?php
namespace Friendica\Navigation\Notifications\Depository;
namespace Friendica\Navigation\Notifications\Repository;
use Friendica\App\BaseURL;
use Friendica\BaseDepository;
use Friendica\BaseRepository;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Hook;
@ -22,7 +22,7 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
use Psr\Log\LoggerInterface;
class Notify extends BaseDepository
class Notify extends BaseRepository
{
/** @var Factory\Notify */
protected $factory;

View file

@ -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\Profile\ProfileField\Exception\ProfileFieldNotFoundException;
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\Entity;
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 Psr\Log\LoggerInterface;
class ProfileField extends BaseDepository
class ProfileField extends BaseRepository
{
/** @var Factory\ProfileField */
protected $factory;
@ -42,14 +42,14 @@ class ProfileField extends BaseDepository
protected static $view_name = 'profile_field-view';
/** @var PermissionSetDepository */
protected $permissionSetDepository;
/** @var PermissionSetRepository */
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);
$this->permissionSetDepository = $permissionSetDepository;
$this->permissionSetRepository = $permissionSetRepository;
}
/**
@ -124,7 +124,7 @@ class ProfileField extends BaseDepository
public function selectPublicFieldsByUserId(int $uid): Collection\ProfileFields
{
try {
$publicPermissionSet = $this->permissionSetDepository->selectPublicForUser($uid);
$publicPermissionSet = $this->permissionSetRepository->selectPublicForUser($uid);
return $this->select([
'uid' => $uid,
@ -162,12 +162,12 @@ class ProfileField extends BaseDepository
*/
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');
// Includes public custom fields
$permissionSetIds[] = $this->permissionSetDepository->selectPublicForUser($uid)->id;
$permissionSetIds[] = $this->permissionSetRepository->selectPublicForUser($uid)->id;
return $this->select(
['uid' => $uid, 'psid' => $permissionSetIds],

View file

@ -3,7 +3,7 @@
namespace Friendica\Security\PermissionSet\Entity;
use Friendica\BaseEntity;
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
/**
* @property-read int|null $id
@ -55,7 +55,7 @@ class PermissionSet extends BaseEntity
*/
public function isPublic(): bool
{
return (($this->id === PermissionSetDepository::PUBLIC) ||
return (($this->id === PermissionSetRepository::PUBLIC) ||
(is_null($this->id) &&
empty($this->allow_cid) &&
empty($this->allow_gid) &&

View file

@ -19,10 +19,10 @@
*
*/
namespace Friendica\Security\PermissionSet\Depository;
namespace Friendica\Security\PermissionSet\Repository;
use Exception;
use Friendica\BaseDepository;
use Friendica\BaseRepository;
use Friendica\Database\Database;
use Friendica\Model\Contact;
use Friendica\Model\Group;
@ -33,7 +33,7 @@ use Friendica\Security\PermissionSet\Entity;
use Friendica\Util\ACLFormatter;
use Psr\Log\LoggerInterface;
class PermissionSet extends BaseDepository
class PermissionSet extends BaseRepository
{
/** @var int Virtual permission set id for public permission */
const PUBLIC = 0;

View file

@ -6,7 +6,7 @@ use Friendica\Profile\ProfileField\Entity\ProfileField;
use Friendica\Profile\ProfileField\Exception\ProfileFieldNotFoundException;
use Friendica\Profile\ProfileField\Exception\UnexpectedPermissionSetException;
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\Test\MockedTest;
use Friendica\Util\ACLFormatter;
@ -16,8 +16,8 @@ use Mockery\MockInterface;
class ProfileFieldTest extends MockedTest
{
/** @var MockInterface|PermissionSetDepository */
protected $permissionSetDepository;
/** @var MockInterface|PermissionSetRepository */
protected $permissionSetRepository;
/** @var ProfileFieldFactory */
protected $profileFieldFactory;
/** @var MockInterface|PermissionSetFactory */
@ -27,7 +27,7 @@ class ProfileFieldTest extends MockedTest
{
parent::setUp();
$this->permissionSetDepository = \Mockery::mock(PermissionSetDepository::class);
$this->permissionSetRepository = \Mockery::mock(PermissionSetRepository::class);
$this->permissionSetFactory = new PermissionSetFactory(new VoidLogger(), new ACLFormatter());
$this->profileFieldFactory = new ProfileFieldFactory(new VoidLogger(), $this->permissionSetFactory);
}
@ -180,7 +180,7 @@ class ProfileFieldTest extends MockedTest
$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);
}

View file

@ -1,27 +1,27 @@
<?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\Depository\ProfileField as ProfileFieldDepository;
use Friendica\Profile\ProfileField\Repository\ProfileField as ProfileFieldRepository;
use Friendica\Profile\ProfileField\Exception\ProfileFieldPersistenceException;
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\Depository\PermissionSet as PermissionSetDepository;
use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository;
use Friendica\Test\FixtureTest;
use Friendica\DI;
class ProfileFieldTest extends FixtureTest
{
/** @var ProfileFieldDepository */
/** @var ProfileFieldRepository */
private $depository;
/** @var ProfileFieldFactory */
private $factory;
/** @var PermissionSetFactory */
private $permissionSetFactory;
/** @var PermissionSetDepository */
private $permissionSetDepository;
/** @var PermissionSetRepository */
private $permissionSetRepository;
public function setUp(): void
{
@ -30,7 +30,7 @@ class ProfileFieldTest extends FixtureTest
$this->depository = DI::profileField();
$this->factory = DI::profileFieldFactory();
$this->permissionSetFactory = DI::permissionSetFactory();
$this->permissionSetDepository = DI::permissionSet();
$this->permissionSetRepository = DI::permissionSet();
}
/**
@ -53,7 +53,7 @@ class ProfileFieldTest extends FixtureTest
*/
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);
@ -75,7 +75,7 @@ class ProfileFieldTest extends FixtureTest
*/
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);
@ -108,7 +108,7 @@ class ProfileFieldTest extends FixtureTest
*/
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);
@ -121,12 +121,12 @@ class ProfileFieldTest extends FixtureTest
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);
$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(5, $publicProfileField->order);

View file

@ -1,8 +1,8 @@
<?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\Factory\PermissionSet as PermissionSetFactory;
use Friendica\Test\FixtureTest;
@ -10,8 +10,8 @@ use Friendica\DI;
class PermissionSetTest extends FixtureTest
{
/** @var PermissionSetDepository */
private $depository;
/** @var PermissionSetRepository */
private $repository;
/** @var PermissionSetFactory */
private $factory;
@ -19,20 +19,20 @@ class PermissionSetTest extends FixtureTest
{
parent::setUp();
$this->depository = DI::permissionSet();
$this->repository = DI::permissionSet();
$this->factory = DI::permissionSetFactory();
}
public function testSelectOneByIdPublic()
{
$permissionSet = $this->depository->selectPublicForUser(1);
$permissionSet = $this->repository->selectPublicForUser(1);
$this->assertInstanceOf(PermissionSet::class, $permissionSet);
self::assertEmpty($permissionSet->allow_cid);
self::assertEmpty($permissionSet->allow_gid);
self::assertEmpty($permissionSet->deny_cid);
self::assertEmpty($permissionSet->deny_gid);
self::assertEmpty(PermissionSetDepository::PUBLIC, $permissionSet->id);
self::assertEmpty(PermissionSetRepository::PUBLIC, $permissionSet->id);
self::assertEquals(1, $permissionSet->uid);
}
@ -43,21 +43,21 @@ class PermissionSetTest extends FixtureTest
{
$permissionSet = $this->factory->createFromString(42, '', '<~>');
$permissionSet = $this->depository->selectOrCreate($permissionSet);
$permissionSet = $this->repository->selectOrCreate($permissionSet);
self::assertNotNull($permissionSet->id);
$permissionSetSelected = $this->depository->selectOneById($permissionSet->id, 42);
$permissionSetSelected = $this->repository->selectOneById($permissionSet->id, 42);
self::assertEquals($permissionSet, $permissionSetSelected);
$newPermissionSet = $permissionSet->withAllowedContacts(['1', '2']);
$savedPermissionSet = $this->depository->save($newPermissionSet);
$savedPermissionSet = $this->repository->save($newPermissionSet);
self::assertNotNull($savedPermissionSet->id);
self::assertNull($newPermissionSet->id);
$permissionSetSavedSelected = $this->depository->selectOneById($savedPermissionSet->id, 42);
$permissionSetSavedSelected = $this->repository->selectOneById($savedPermissionSet->id, 42);
self::assertEquals($savedPermissionSet, $permissionSetSavedSelected);
}

View file

@ -55,7 +55,7 @@ use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\Profile;
use Friendica\Model\Storage;
use Friendica\Security\PermissionSet\Depository\PermissionSet;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
use Friendica\Worker\Delivery;
// Post-update script of PR 5751