Skip to content

Commit

Permalink
chore: Move Providers
Browse files Browse the repository at this point in the history
Signed-off-by: Rubén D <[email protected]>
  • Loading branch information
nuxsmin committed Apr 28, 2024
1 parent e916420 commit 04d2459
Show file tree
Hide file tree
Showing 88 changed files with 376 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Import\Services\ImportStrategy;
use SP\Domain\Plugin\Ports\PluginManagerService;
use SP\Domain\Providers\Browser\BrowserAuthService;
use SP\Infrastructure\File\FileException;
use SP\Modules\Web\Controllers\SimpleControllerBase;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Mvc\Controller\SimpleControllerHelper;
use SP\Providers\Auth\Browser\BrowserAuthService;

use function SP\logger;
use function SP\processException;
Expand Down
6 changes: 3 additions & 3 deletions app/modules/web/Controllers/ConfigLdap/ConfigLdapTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
Expand All @@ -26,8 +26,8 @@

use SP\Domain\Core\Exceptions\ValidationException;
use SP\Domain\Http\RequestInterface;
use SP\Providers\Auth\Ldap\LdapParams;
use SP\Providers\Auth\Ldap\LdapTypeEnum;
use SP\Domain\Providers\Ldap\LdapParams;
use SP\Domain\Providers\Ldap\LdapTypeEnum;

use function SP\__u;

Expand Down
2 changes: 1 addition & 1 deletion app/modules/web/Controllers/ConfigMail/CheckController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Core\Exceptions\ValidationException;
use SP\Domain\Notification\Ports\MailService;
use SP\Domain\Providers\Mail\MailParams;
use SP\Http\JsonMessage;
use SP\Modules\Web\Controllers\SimpleControllerBase;
use SP\Modules\Web\Controllers\Traits\ConfigTrait;
use SP\Mvc\Controller\SimpleControllerHelper;
use SP\Providers\Mail\MailParams;

/**
* Class CheckController
Expand Down
10 changes: 5 additions & 5 deletions app/modules/web/Controllers/ConfigManager/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
use SP\Domain\Crypt\Services\TemporaryMasterPass;
use SP\Domain\Export\Services\BackupFileHelper;
use SP\Domain\Export\Services\XmlExport;
use SP\Domain\Providers\Ldap\LdapMsAds;
use SP\Domain\Providers\Ldap\LdapStd;
use SP\Domain\Providers\Ldap\LdapTypeEnum;
use SP\Domain\Providers\Log\LogInterface;
use SP\Domain\Providers\Mail\MailHandler;
use SP\Domain\Task\Services\Task;
use SP\Domain\User\Ports\UserGroupService;
use SP\Domain\User\Ports\UserProfileService;
Expand All @@ -61,11 +66,6 @@
use SP\Mvc\View\Components\DataTab;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Plugin\PluginManager;
use SP\Providers\Auth\Ldap\LdapMsAds;
use SP\Providers\Auth\Ldap\LdapStd;
use SP\Providers\Auth\Ldap\LdapTypeEnum;
use SP\Providers\Log\LogInterface;
use SP\Providers\Mail\MailHandler;
use SP\Util\Util;

/**
Expand Down
2 changes: 1 addition & 1 deletion app/modules/web/Controllers/ControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
use SP\Domain\Core\PhpExtensionCheckerService;
use SP\Domain\Core\UI\ThemeInterface;
use SP\Domain\Http\RequestInterface;
use SP\Domain\Providers\Browser\BrowserAuthService;
use SP\Domain\User\Dtos\UserDataDto;
use SP\Domain\User\Models\ProfileData;
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
use SP\Modules\Web\Controllers\Traits\WebControllerTrait;
use SP\Mvc\Controller\WebControllerHelper;
use SP\Mvc\View\TemplateInterface;
use SP\Providers\Auth\Browser\BrowserAuthService;

use function SP\__;
use function SP\logger;
Expand Down
42 changes: 21 additions & 21 deletions lib/SP/Core/Definitions/CoreDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,27 @@
use SP\Domain\Install\Services\DatabaseSetupInterface;
use SP\Domain\Install\Services\MysqlSetupBuilder;
use SP\Domain\Notification\Services\Mail;
use SP\Domain\Providers\MailerInterface;
use SP\Domain\Providers\Acl\AclHandler;
use SP\Domain\Providers\Auth\AuthProvider;
use SP\Domain\Providers\Auth\AuthProviderService;
use SP\Domain\Providers\Auth\AuthType;
use SP\Domain\Providers\Browser\BrowserAuth;
use SP\Domain\Providers\Browser\BrowserAuthService;
use SP\Domain\Providers\Database\DatabaseAuth;
use SP\Domain\Providers\Database\DatabaseAuthService;
use SP\Domain\Providers\Ldap\LdapActions;
use SP\Domain\Providers\Ldap\LdapAuth;
use SP\Domain\Providers\Ldap\LdapBase;
use SP\Domain\Providers\Ldap\LdapConnection;
use SP\Domain\Providers\Ldap\LdapParams;
use SP\Domain\Providers\Log\DatabaseLogHandler;
use SP\Domain\Providers\Log\FileLogHandler;
use SP\Domain\Providers\Log\RemoteSyslogHandler;
use SP\Domain\Providers\Log\SyslogHandler;
use SP\Domain\Providers\Mail\MailHandler;
use SP\Domain\Providers\Mail\PhpMailerWrapper;
use SP\Domain\Providers\Notification\NotificationHandler;
use SP\Domain\Providers\Ports\MailerInterface;
use SP\Domain\Storage\Ports\FileCacheService;
use SP\Html\Minify;
use SP\Http\Client;
Expand All @@ -89,26 +109,6 @@
use SP\Infrastructure\File\XmlFileStorage;
use SP\Mvc\View\Template;
use SP\Mvc\View\TemplateInterface;
use SP\Providers\Acl\AclHandler;
use SP\Providers\Auth\AuthProvider;
use SP\Providers\Auth\AuthProviderService;
use SP\Providers\Auth\AuthType;
use SP\Providers\Auth\Browser\BrowserAuth;
use SP\Providers\Auth\Browser\BrowserAuthService;
use SP\Providers\Auth\Database\DatabaseAuth;
use SP\Providers\Auth\Database\DatabaseAuthService;
use SP\Providers\Auth\Ldap\LdapActions;
use SP\Providers\Auth\Ldap\LdapAuth;
use SP\Providers\Auth\Ldap\LdapBase;
use SP\Providers\Auth\Ldap\LdapConnection;
use SP\Providers\Auth\Ldap\LdapParams;
use SP\Providers\Log\DatabaseLogHandler;
use SP\Providers\Log\FileLogHandler;
use SP\Providers\Log\RemoteSyslogHandler;
use SP\Providers\Log\SyslogHandler;
use SP\Providers\Mail\MailHandler;
use SP\Providers\Mail\PhpMailerWrapper;
use SP\Providers\Notification\NotificationHandler;

use function DI\autowire;
use function DI\create;
Expand Down
21 changes: 10 additions & 11 deletions lib/SP/Core/Events/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,31 @@
namespace SP\Core\Events;

use SP\Domain\Core\Exceptions\InvalidClassException;
use SP\Domain\Core\Exceptions\SPException;

/**
* Class Event
*/
class Event
readonly class Event
{
public function __construct(
private readonly object $source,
private readonly ?EventMessage $eventMessage = null
private object $source,
private ?EventMessage $eventMessage = null
) {
}

/**
* @template T of object
*
* @param class-string<T>|null $type
* @return T&object
* @throws InvalidClassException
*/
public function getSource(?string $type = null): object
{
if ($type !== null
&& ($source = get_class($this->source)) !== $type
&& !is_subclass_of($this->source, $type)
) {
throw new InvalidClassException(
if ($type !== null && !is_a($this->source, $type)) {
throw InvalidClassException::error(
'Source type mismatch',
SPException::ERROR,
sprintf('Source: %s - Expected: %s', $source, $type)
sprintf('Source: %s - Expected: %s', get_class($this->source), $type)
);
}

Expand Down
38 changes: 8 additions & 30 deletions lib/SP/Core/ProvidersHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
Expand All @@ -24,14 +24,13 @@

namespace SP\Core;

use SP\Providers\Acl\AclHandler;
use SP\Providers\Log\DatabaseLogHandler;
use SP\Providers\Log\FileLogHandler;
use SP\Providers\Log\RemoteSyslogHandler;
use SP\Providers\Log\SyslogHandler;
use SP\Providers\Mail\MailHandler;
use SP\Providers\Notification\NotificationHandler;
use SP\Providers\ProviderInterface;
use SP\Domain\Providers\Acl\AclHandler;
use SP\Domain\Providers\Log\DatabaseLogHandler;
use SP\Domain\Providers\Log\FileLogHandler;
use SP\Domain\Providers\Log\RemoteSyslogHandler;
use SP\Domain\Providers\Log\SyslogHandler;
use SP\Domain\Providers\Mail\MailHandler;
use SP\Domain\Providers\Notification\NotificationHandler;

/**
* The Provider helper class will have oll the providers availabe in the application
Expand All @@ -52,57 +51,36 @@ public function __construct(

public function getFileLogHandler(): FileLogHandler
{
self::ensureIsInitialized($this->fileLogHandler);

return $this->fileLogHandler;
}

private static function ensureIsInitialized(?ProviderInterface $provider = null): void
{
if ($provider !== null && !$provider->isInitialized()) {
$provider->initialize();
}
}

public function getDatabaseLogHandler(): DatabaseLogHandler
{
self::ensureIsInitialized($this->databaseLogHandler);

return $this->databaseLogHandler;
}

public function getMailHandler(): MailHandler
{
self::ensureIsInitialized($this->mailHandler);

return $this->mailHandler;
}

public function getSyslogHandler(): SyslogHandler
{
self::ensureIsInitialized($this->syslogHandler);

return $this->syslogHandler;
}

public function getRemoteSyslogHandler(): RemoteSyslogHandler
{
self::ensureIsInitialized($this->remoteSyslogHandler);

return $this->remoteSyslogHandler;
}

public function getAclHandler(): AclHandler
{
self::ensureIsInitialized($this->aclHandler);

return $this->aclHandler;
}

public function getNotificationHandler(): NotificationHandler
{
self::ensureIsInitialized($this->notificationHandler);

return $this->notificationHandler;
}
}
10 changes: 5 additions & 5 deletions lib/SP/Domain/Auth/Ports/LdapActionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

namespace SP\Domain\Auth\Ports;

use SP\Providers\Auth\Ldap\AttributeCollection;
use SP\Providers\Auth\Ldap\LdapException;
use SP\Providers\Auth\Ldap\LdapParams;
use SP\Providers\Auth\Ldap\LdapResults;
use SP\Domain\Providers\Ldap\AttributeCollection;
use SP\Domain\Providers\Ldap\LdapException;
use SP\Domain\Providers\Ldap\LdapParams;
use SP\Domain\Providers\Ldap\LdapResults;

/**
* Class LdapActions
*
* @package SP\Providers\Auth\Ldap
* @package SP\Domain\Providers\Ldap
*/
interface LdapActionsService
{
Expand Down
4 changes: 2 additions & 2 deletions lib/SP/Domain/Auth/Ports/LdapAuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

namespace SP\Domain\Auth\Ports;

use SP\Providers\Auth\AuthService;
use SP\Providers\Auth\Ldap\LdapAuthData;
use SP\Domain\Providers\Auth\AuthService;
use SP\Domain\Providers\Ldap\LdapAuthData;

/**
* Class LdapBase
Expand Down
2 changes: 1 addition & 1 deletion lib/SP/Domain/Auth/Ports/LdapCheckService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


use SP\Domain\Auth\Dtos\LdapCheckResults;
use SP\Providers\Auth\Ldap\LdapException;
use SP\Domain\Providers\Ldap\LdapException;

/**
* Class LdapCheckService
Expand Down
6 changes: 3 additions & 3 deletions lib/SP/Domain/Auth/Ports/LdapConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
Expand All @@ -24,8 +24,8 @@

namespace SP\Domain\Auth\Ports;

use SP\Providers\Auth\Ldap\LdapException;
use SP\Providers\Auth\Ldap\LdapParams;
use SP\Domain\Providers\Ldap\LdapException;
use SP\Domain\Providers\Ldap\LdapParams;

/**
* Interface LdapInterface
Expand Down
4 changes: 2 additions & 2 deletions lib/SP/Domain/Auth/Ports/LdapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
namespace SP\Domain\Auth\Ports;


use SP\Providers\Auth\Ldap\LdapException;
use SP\Domain\Providers\Ldap\LdapException;

/**
* Interface LdapInterface
*
* @package SP\Providers\Auth\Ldap
* @package SP\Domain\Providers\Ldap
*/
interface LdapService
{
Expand Down
6 changes: 3 additions & 3 deletions lib/SP/Domain/Auth/Ports/LoginAuthHandlerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

use SP\Domain\Auth\Dtos\UserLoginDto;
use SP\Domain\Auth\Services\AuthException;
use SP\Providers\Auth\Browser\BrowserAuthData;
use SP\Providers\Auth\Database\DatabaseAuthData;
use SP\Providers\Auth\Ldap\LdapAuthData;
use SP\Domain\Providers\Browser\BrowserAuthData;
use SP\Domain\Providers\Database\DatabaseAuthData;
use SP\Domain\Providers\Ldap\LdapAuthData;

/**
* Class LoginDatabase
Expand Down
2 changes: 1 addition & 1 deletion lib/SP/Domain/Auth/Ports/LoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

use SP\Domain\Auth\Dtos\LoginResponseDto;
use SP\Domain\Auth\Services\AuthException;
use SP\Providers\Auth\AuthResult;
use SP\Domain\Providers\Auth\AuthResult;

/**
* Interface LoginService
Expand Down
6 changes: 3 additions & 3 deletions lib/SP/Domain/Auth/Services/LdapCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
use SP\Domain\Auth\Ports\LdapConnectionInterface;
use SP\Domain\Auth\Ports\LdapService;
use SP\Domain\Common\Services\Service;
use SP\Providers\Auth\Ldap\LdapBase;
use SP\Providers\Auth\Ldap\LdapException;
use SP\Providers\Auth\Ldap\LdapParams;
use SP\Domain\Providers\Ldap\LdapBase;
use SP\Domain\Providers\Ldap\LdapException;
use SP\Domain\Providers\Ldap\LdapParams;

/**
* Class LdapCheck
Expand Down
Loading

0 comments on commit 04d2459

Please sign in to comment.