|
@@ -83,40 +83,9 @@ class AccountManager implements IAccountManager {
|
|
|
|
|
|
use TProfileHelper;
|
|
|
|
|
|
- /** @var IDBConnection database connection */
|
|
|
- private $connection;
|
|
|
-
|
|
|
- /** @var IConfig */
|
|
|
- private $config;
|
|
|
-
|
|
|
- /** @var string table name */
|
|
|
- private $table = 'accounts';
|
|
|
-
|
|
|
- /** @var string table name */
|
|
|
- private $dataTable = 'accounts_data';
|
|
|
-
|
|
|
- /** @var EventDispatcherInterface */
|
|
|
- private $eventDispatcher;
|
|
|
-
|
|
|
- /** @var IJobList */
|
|
|
- private $jobList;
|
|
|
-
|
|
|
- /** @var LoggerInterface */
|
|
|
- private $logger;
|
|
|
- /** @var IVerificationToken */
|
|
|
- private $verificationToken;
|
|
|
- /** @var IMailer */
|
|
|
- private $mailer;
|
|
|
- /** @var Defaults */
|
|
|
- private $defaults;
|
|
|
- /** @var IL10N */
|
|
|
- private $l10n;
|
|
|
- /** @var IURLGenerator */
|
|
|
- private $urlGenerator;
|
|
|
- /** @var ICrypto */
|
|
|
- private $crypto;
|
|
|
- /** @var IFactory */
|
|
|
- private $l10nfactory;
|
|
|
+ private string $table = 'accounts';
|
|
|
+ private string $dataTable = 'accounts_data';
|
|
|
+ private ?IL10N $l10n = null;
|
|
|
private CappedMemoryCache $internalCache;
|
|
|
|
|
|
/**
|
|
@@ -138,35 +107,22 @@ class AccountManager implements IAccountManager {
|
|
|
];
|
|
|
|
|
|
public function __construct(
|
|
|
- IDBConnection $connection,
|
|
|
- IConfig $config,
|
|
|
- EventDispatcherInterface $eventDispatcher,
|
|
|
- IJobList $jobList,
|
|
|
- LoggerInterface $logger,
|
|
|
- IVerificationToken $verificationToken,
|
|
|
- IMailer $mailer,
|
|
|
- Defaults $defaults,
|
|
|
- IFactory $factory,
|
|
|
- IURLGenerator $urlGenerator,
|
|
|
- ICrypto $crypto
|
|
|
+ private IDBConnection $connection,
|
|
|
+ private IConfig $config,
|
|
|
+ private EventDispatcherInterface $eventDispatcher,
|
|
|
+ private IJobList $jobList,
|
|
|
+ private LoggerInterface $logger,
|
|
|
+ private IVerificationToken $verificationToken,
|
|
|
+ private IMailer $mailer,
|
|
|
+ private Defaults $defaults,
|
|
|
+ private IFactory $l10nFactory,
|
|
|
+ private IURLGenerator $urlGenerator,
|
|
|
+ private ICrypto $crypto,
|
|
|
) {
|
|
|
- $this->connection = $connection;
|
|
|
- $this->config = $config;
|
|
|
- $this->eventDispatcher = $eventDispatcher;
|
|
|
- $this->jobList = $jobList;
|
|
|
- $this->logger = $logger;
|
|
|
- $this->verificationToken = $verificationToken;
|
|
|
- $this->mailer = $mailer;
|
|
|
- $this->defaults = $defaults;
|
|
|
- $this->urlGenerator = $urlGenerator;
|
|
|
- $this->crypto = $crypto;
|
|
|
- // DIing IL10N results in a dependency loop
|
|
|
- $this->l10nfactory = $factory;
|
|
|
$this->internalCache = new CappedMemoryCache();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param string $input
|
|
|
* @return string Provided phone number in E.164 format when it was a valid number
|
|
|
* @throws InvalidArgumentException When the phone number was invalid or no default region is set and the number doesn't start with a country code
|
|
|
*/
|
|
@@ -195,9 +151,6 @@ class AccountManager implements IAccountManager {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param string $input
|
|
|
- * @return string
|
|
|
* @throws InvalidArgumentException When the website did not have http(s) as protocol or the host name was empty
|
|
|
*/
|
|
|
protected function parseWebsite(string $input): string {
|
|
@@ -251,7 +204,7 @@ class AccountManager implements IAccountManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected function sanitizePhoneNumberValue(IAccountProperty $property, bool $throwOnData = false) {
|
|
|
+ protected function sanitizePhoneNumberValue(IAccountProperty $property, bool $throwOnData = false): void {
|
|
|
if ($property->getName() !== self::PROPERTY_PHONE) {
|
|
|
if ($throwOnData) {
|
|
|
throw new InvalidArgumentException(sprintf('sanitizePhoneNumberValue can only sanitize phone numbers, %s given', $property->getName()));
|
|
@@ -271,7 +224,7 @@ class AccountManager implements IAccountManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected function sanitizeWebsite(IAccountProperty $property, bool $throwOnData = false) {
|
|
|
+ protected function sanitizeWebsite(IAccountProperty $property, bool $throwOnData = false): void {
|
|
|
if ($property->getName() !== self::PROPERTY_WEBSITE) {
|
|
|
if ($throwOnData) {
|
|
|
throw new InvalidArgumentException(sprintf('sanitizeWebsite can only sanitize web domains, %s given', $property->getName()));
|
|
@@ -313,10 +266,8 @@ class AccountManager implements IAccountManager {
|
|
|
|
|
|
/**
|
|
|
* delete user from accounts table
|
|
|
- *
|
|
|
- * @param IUser $user
|
|
|
*/
|
|
|
- public function deleteUser(IUser $user) {
|
|
|
+ public function deleteUser(IUser $user): void {
|
|
|
$uid = $user->getUID();
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
$query->delete($this->table)
|
|
@@ -328,8 +279,6 @@ class AccountManager implements IAccountManager {
|
|
|
|
|
|
/**
|
|
|
* delete user from accounts table
|
|
|
- *
|
|
|
- * @param IUser $user
|
|
|
*/
|
|
|
public function deleteUserData(IUser $user): void {
|
|
|
$uid = $user->getUID();
|
|
@@ -398,12 +347,10 @@ class AccountManager implements IAccountManager {
|
|
|
}
|
|
|
|
|
|
protected function searchUsersForRelatedCollection(string $property, array $values): array {
|
|
|
- switch ($property) {
|
|
|
- case IAccountManager::PROPERTY_EMAIL:
|
|
|
- return array_flip($this->searchUsers(IAccountManager::COLLECTION_EMAIL, $values));
|
|
|
- default:
|
|
|
- return [];
|
|
|
- }
|
|
|
+ return match ($property) {
|
|
|
+ IAccountManager::PROPERTY_EMAIL => array_flip($this->searchUsers(IAccountManager::COLLECTION_EMAIL, $values)),
|
|
|
+ default => [],
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -467,7 +414,7 @@ class AccountManager implements IAccountManager {
|
|
|
]);
|
|
|
|
|
|
if (!$this->l10n) {
|
|
|
- $this->l10n = $this->l10nfactory->get('core');
|
|
|
+ $this->l10n = $this->l10nFactory->get('core');
|
|
|
}
|
|
|
|
|
|
$emailTemplate->setSubject($this->l10n->t('%s email verification', [$this->defaults->getName()]));
|
|
@@ -552,9 +499,6 @@ class AccountManager implements IAccountManager {
|
|
|
|
|
|
/**
|
|
|
* add new user to accounts table
|
|
|
- *
|
|
|
- * @param IUser $user
|
|
|
- * @param array $data
|
|
|
*/
|
|
|
protected function insertNewUser(IUser $user, array $data): void {
|
|
|
$uid = $user->getUID();
|