Skip to content

Commit

Permalink
refactor: create provider files
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Nov 5, 2024
1 parent a894c77 commit 1290d3b
Show file tree
Hide file tree
Showing 46 changed files with 669 additions and 612 deletions.
2 changes: 1 addition & 1 deletion config.local.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
'ps_accounts.oauth2_url' => 'https://oauth.prestashop.local',

'ps_accounts.testimonials_url' => 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json',
'ps_accounts.log_level' => 'DEBUG',
'ps_accounts.log_level' => 'ERROR',
];
19 changes: 1 addition & 18 deletions src/Account/CommandHandler/DeleteUserShopHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient;
use PrestaShop\Module\PsAccounts\Context\ShopContext;
use PrestaShop\Module\PsAccounts\Exception\RefreshTokenException;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class DeleteUserShopHandler implements IServiceContainerService
class DeleteUserShopHandler
{
/**
* @var AccountsClient
Expand Down Expand Up @@ -89,19 +87,4 @@ public function handle(DeleteUserShopCommand $command)
);
});
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(AccountsClient::class),
$serviceContainer->get(ShopContext::class),
$serviceContainer->get(ShopSession::class),
$serviceContainer->get(OwnerSession::class)
);
}
}
16 changes: 1 addition & 15 deletions src/Account/CommandHandler/LinkShopHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
use PrestaShop\Module\PsAccounts\Account\Command\LinkShopCommand;
use PrestaShop\Module\PsAccounts\Account\LinkShop;
use PrestaShop\Module\PsAccounts\Hook\ActionShopAccountLinkAfter;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;
use PrestaShopException;

class LinkShopHandler implements IServiceContainerService
class LinkShopHandler
{
/**
* @var LinkShop
Expand Down Expand Up @@ -56,16 +54,4 @@ public function handle(LinkShopCommand $command)
'shopId' => $command->payload->shopId,
]);
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(LinkShop::class)
);
}
}
75 changes: 0 additions & 75 deletions src/Account/CommandHandler/MigrateAndLinkV4ShopHandler.php

This file was deleted.

18 changes: 1 addition & 17 deletions src/Account/CommandHandler/UnlinkShopHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
use PrestaShop\Module\PsAccounts\Hook\ActionShopAccountUnlinkAfter;
use PrestaShop\Module\PsAccounts\Provider\ShopProvider;
use PrestaShop\Module\PsAccounts\Service\AnalyticsService;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class UnlinkShopHandler implements IServiceContainerService
class UnlinkShopHandler
{
/**
* @var LinkShop
Expand Down Expand Up @@ -101,18 +99,4 @@ public function handle(UnlinkShopCommand $command)

Hook::exec(ActionShopAccountUnlinkAfter::getName(), $hookData);
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(LinkShop::class),
$serviceContainer->get(AnalyticsService::class),
$serviceContainer->get(ShopProvider::class)
);
}
}
19 changes: 1 addition & 18 deletions src/Account/CommandHandler/UpdateUserShopHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient;
use PrestaShop\Module\PsAccounts\Context\ShopContext;
use PrestaShop\Module\PsAccounts\Exception\RefreshTokenException;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class UpdateUserShopHandler implements IServiceContainerService
class UpdateUserShopHandler
{
/**
* @var AccountsClient
Expand Down Expand Up @@ -90,19 +88,4 @@ public function handle(UpdateUserShopCommand $command)
);
});
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(AccountsClient::class),
$serviceContainer->get(ShopContext::class),
$serviceContainer->get(ShopSession::class),
$serviceContainer->get(OwnerSession::class)
);
}
}
21 changes: 1 addition & 20 deletions src/Account/CommandHandler/UpgradeModuleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
use PrestaShop\Module\PsAccounts\Exception\RefreshTokenException;
use PrestaShop\Module\PsAccounts\Log\Logger;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class UpgradeModuleHandler implements IServiceContainerService
class UpgradeModuleHandler
{
/**
* @var LinkShop
Expand Down Expand Up @@ -166,21 +164,4 @@ private function lastChanceToRefreshShopToken()
$tokens['refresh_token']
);
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(AccountsClient::class),
$serviceContainer->get(LinkShop::class),
$serviceContainer->get(ShopSession::class),
$serviceContainer->get(ShopContext::class),
$serviceContainer->get(ConfigurationRepository::class),
$serviceContainer->get(CommandBus::class)
);
}
}
17 changes: 1 addition & 16 deletions src/Account/CommandHandler/UpgradeModuleMultiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
use PrestaShop\Module\PsAccounts\Exception\DtoException;
use PrestaShop\Module\PsAccounts\Exception\RefreshTokenException;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;
use PrestaShopDatabaseException;

class UpgradeModuleMultiHandler implements IServiceContainerService
class UpgradeModuleMultiHandler
{
/**
* @var ConfigurationRepository
Expand Down Expand Up @@ -95,17 +93,4 @@ private function getShops($multishop)

return $shops;
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(CommandBus::class),
$serviceContainer->get(ConfigurationRepository::class)
);
}
}
16 changes: 1 addition & 15 deletions src/Account/LinkShop.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
namespace PrestaShop\Module\PsAccounts\Account;

use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class LinkShop implements IServiceContainerService
class LinkShop
{
/**
* @var ConfigurationRepository
Expand Down Expand Up @@ -191,16 +189,4 @@ public function setUnlinkedOnError($errorMsg)
{
$this->configuration->updateUnlinkedOnError($errorMsg);
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(ConfigurationRepository::class)
);
}
}
17 changes: 1 addition & 16 deletions src/Account/Session/Firebase/OwnerSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
use PrestaShop\Module\PsAccounts\Account\Session\SessionInterface;
use PrestaShop\Module\PsAccounts\Account\Token\Token;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class OwnerSession extends FirebaseSession implements SessionInterface, IServiceContainerService
class OwnerSession extends FirebaseSession implements SessionInterface
{
/**
* @var ConfigurationRepository
Expand Down Expand Up @@ -75,17 +73,4 @@ public function setToken($token, $refreshToken = null)
{
$this->configurationRepository->updateUserFirebaseIdAndRefreshToken($token, $refreshToken);
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(ConfigurationRepository::class),
$serviceContainer->get(\PrestaShop\Module\PsAccounts\Account\Session\ShopSession::class)
);
}
}
17 changes: 1 addition & 16 deletions src/Account/Session/Firebase/ShopSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
use PrestaShop\Module\PsAccounts\Account\Session\SessionInterface;
use PrestaShop\Module\PsAccounts\Account\Token\Token;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;

class ShopSession extends FirebaseSession implements SessionInterface, IServiceContainerService
class ShopSession extends FirebaseSession implements SessionInterface
{
/**
* @var ConfigurationRepository
Expand Down Expand Up @@ -75,17 +73,4 @@ public function setToken($token, $refreshToken = null)
{
$this->configurationRepository->updateFirebaseIdAndRefreshTokens($token, $refreshToken);
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(ConfigurationRepository::class),
$serviceContainer->get(\PrestaShop\Module\PsAccounts\Account\Session\ShopSession::class)
);
}
}
19 changes: 1 addition & 18 deletions src/Account/Session/ShopSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
use PrestaShop\Module\PsAccounts\Log\Logger;
use PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
use PrestaShop\Module\PsAccounts\ServiceContainer\IServiceContainerService;
use PrestaShop\Module\PsAccounts\ServiceContainer\ServiceContainer;
use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Grant\ClientCredentials;
use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Token\AccessToken;
use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Token\AccessTokenInterface;

class ShopSession extends Session implements SessionInterface, IServiceContainerService
class ShopSession extends Session implements SessionInterface
{
/**
* @var CommandBus
Expand Down Expand Up @@ -205,19 +203,4 @@ private function getShopUuid()
{
return $this->linkShop->getShopUuid();
}

/**
* @param ServiceContainer $serviceContainer
*
* @return self
*/
public static function getInstance(ServiceContainer $serviceContainer)
{
return new self(
$serviceContainer->get(ConfigurationRepository::class),
$serviceContainer->get(ShopProvider::class),
$serviceContainer->get(LinkShop::class),
$serviceContainer->get(CommandBus::class)
);
}
}
Loading

0 comments on commit 1290d3b

Please sign in to comment.