Skip to content

Commit

Permalink
Merge pull request #4 from spryker/feature/acp-2234/master-automatic-…
Browse files Browse the repository at this point in the history
…payment-method-domain-registration-for-stripe-connected-accounts

Feature/acp 2234/master automatic payment method domain registration for stripe connected accounts
  • Loading branch information
stereomon authored Jan 25, 2024
2 parents 06f320a + 9f431ac commit 28c3cc5
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 91 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ tests/bin/console app-kernel:setup
tests/bin/console transfer:generate
tests/bin/console transfer:databuilder:generate
tests/bin/console propel:install
tests/bin/console dev:ide-auto-completion:zed:generate
tests/bin/console dev:ide-auto-completion:glue:generate
tests/bin/console dev:ide-auto-completion:glue-backend:generate
```

With these commands you've set up the AppKernel and can start the tests
Expand Down
68 changes: 32 additions & 36 deletions src/Spryker/Zed/AppKernel/AppKernelDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
use Spryker\Zed\AppKernel\Dependency\Client\AppKernelToSecretsManagerClientBridge;
use Spryker\Zed\AppKernel\Dependency\Service\AppKernelToUtilEncodingServiceBridge;
use Spryker\Zed\AppKernel\Dependency\Service\AppKernelToUtilTextServiceBridge;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterSavePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeSavePluginInterface;
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
use Spryker\Zed\Kernel\Container;

Expand All @@ -40,22 +36,22 @@ class AppKernelDependencyProvider extends AbstractBundleDependencyProvider
/**
* @var string
*/
public const PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGIN = 'APP_KERNEL:PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGIN';
public const PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGINS = 'APP_KERNEL:PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGINS';

/**
* @var string
*/
public const PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGIN = 'APP_KERNEL:PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGIN';
public const PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGINS = 'APP_KERNEL:PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGINS';

/**
* @var string
*/
public const PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGIN = 'APP_KERNEL:PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGIN';
public const PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGINS = 'APP_KERNEL:PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGINS';

/**
* @var string
*/
public const PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGIN = 'APP_KERNEL:PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGIN';
public const PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGINS = 'APP_KERNEL:PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGINS';

/**
* @param \Spryker\Zed\Kernel\Container $container
Expand All @@ -68,10 +64,10 @@ public function provideBusinessLayerDependencies(Container $container): Containe
$container = $this->addSecretsManagerClient($container);
$container = $this->addUtilTextService($container);
$container = $this->addUtilEncodingService($container);
$container = $this->addConfigurationBeforeSavePlugin($container);
$container = $this->addConfigurationAfterSavePlugin($container);
$container = $this->addConfigurationBeforeDeletePlugin($container);
$container = $this->addConfigurationAfterDeletePlugin($container);
$container = $this->addConfigurationBeforeSavePlugins($container);
$container = $this->addConfigurationAfterSavePlugins($container);
$container = $this->addConfigurationBeforeDeletePlugins($container);
$container = $this->addConfigurationAfterDeletePlugins($container);

return $container;
}
Expand Down Expand Up @@ -136,86 +132,86 @@ protected function addUtilEncodingService(Container $container): Container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addConfigurationBeforeSavePlugin(Container $container): Container
protected function addConfigurationBeforeSavePlugins(Container $container): Container
{
$container->set(static::PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGIN, function (Container $container) {
return $this->getConfigurationBeforeSavePlugin();
$container->set(static::PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGINS, function (Container $container) {
return $this->getConfigurationBeforeSavePlugins();
});

return $container;
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeSavePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeSavePluginInterface>
*/
protected function getConfigurationBeforeSavePlugin(): ?ConfigurationBeforeSavePluginInterface
protected function getConfigurationBeforeSavePlugins(): array
{
return null;
return [];
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addConfigurationAfterSavePlugin(Container $container): Container
protected function addConfigurationAfterSavePlugins(Container $container): Container
{
$container->set(static::PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGIN, function (Container $container) {
return $this->getConfigurationAfterSavePlugin();
$container->set(static::PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGINS, function (Container $container) {
return $this->getConfigurationAfterSavePlugins();
});

return $container;
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterSavePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterSavePluginInterface>
*/
protected function getConfigurationAfterSavePlugin(): ?ConfigurationAfterSavePluginInterface
protected function getConfigurationAfterSavePlugins(): array
{
return null;
return [];
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addConfigurationBeforeDeletePlugin(Container $container): Container
protected function addConfigurationBeforeDeletePlugins(Container $container): Container
{
$container->set(static::PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGIN, function (Container $container) {
return $this->getConfigurationBeforeDeletePlugin();
$container->set(static::PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGINS, function (Container $container) {
return $this->getConfigurationBeforeDeletePlugins();
});

return $container;
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface>
*/
protected function getConfigurationBeforeDeletePlugin(): ?ConfigurationBeforeDeletePluginInterface
protected function getConfigurationBeforeDeletePlugins(): array
{
return null;
return [];
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addConfigurationAfterDeletePlugin(Container $container): Container
protected function addConfigurationAfterDeletePlugins(Container $container): Container
{
$container->set(static::PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGIN, function (Container $container) {
return $this->getConfigurationAfterDeletePlugin();
$container->set(static::PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGINS, function (Container $container) {
return $this->getConfigurationAfterDeletePlugins();
});

return $container;
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface>
*/
protected function getConfigurationAfterDeletePlugin(): ?ConfigurationAfterDeletePluginInterface
protected function getConfigurationAfterDeletePlugins(): array
{
return null;
return [];
}
}
37 changes: 17 additions & 20 deletions src/Spryker/Zed/AppKernel/Business/AppKernelBusinessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
use Spryker\Zed\AppKernel\Business\Writer\ConfigWriterInterface;
use Spryker\Zed\AppKernel\Dependency\Client\AppKernelToSecretsManagerClientInterface;
use Spryker\Zed\AppKernel\Dependency\Service\AppKernelToUtilTextServiceInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterSavePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeSavePluginInterface;
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;

/**
Expand All @@ -40,9 +36,10 @@ public function createConfigWriter(): ConfigWriterInterface
{
return new ConfigWriter(
$this->getEntityManager(),
$this->getRepository(),
$this->createPropelEncryptionConfigurator(),
$this->getConfigurationBeforeSavePlugin(),
$this->getConfigurationAfterSavePlugin(),
$this->getConfigurationBeforeSavePlugins(),
$this->getConfigurationAfterSavePlugins(),
);
}

Expand All @@ -53,8 +50,8 @@ public function createConfigDeleter(): ConfigDeleterInterface
{
return new ConfigDeleter(
$this->getEntityManager(),
$this->getConfigurationBeforeDeletePlugin(),
$this->getConfigurationAfterDeletePlugin(),
$this->getConfigurationBeforeDeletePlugins(),
$this->getConfigurationAfterDeletePlugins(),
);
}

Expand Down Expand Up @@ -107,34 +104,34 @@ public function getTextServiceUtil(): AppKernelToUtilTextServiceInterface
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeSavePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeSavePluginInterface>
*/
public function getConfigurationBeforeSavePlugin(): ?ConfigurationBeforeSavePluginInterface
public function getConfigurationBeforeSavePlugins(): array
{
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGIN);
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_BEFORE_SAVE_PLUGINS);
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterSavePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterSavePluginInterface>
*/
public function getConfigurationAfterSavePlugin(): ?ConfigurationAfterSavePluginInterface
public function getConfigurationAfterSavePlugins(): array
{
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGIN);
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_AFTER_SAVE_PLUGINS);
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface>
*/
public function getConfigurationBeforeDeletePlugin(): ?ConfigurationBeforeDeletePluginInterface
public function getConfigurationBeforeDeletePlugins(): array
{
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGIN);
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_BEFORE_DELETE_PLUGINS);
}

/**
* @return \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface|null
* @return array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface>
*/
public function getConfigurationAfterDeletePlugin(): ?ConfigurationAfterDeletePluginInterface
public function getConfigurationAfterDeletePlugins(): array
{
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGIN);
return $this->getProvidedDependency(AppKernelDependencyProvider::PLUGIN_CONFIGURATION_AFTER_DELETE_PLUGINS);
}
}
42 changes: 30 additions & 12 deletions src/Spryker/Zed/AppKernel/Business/Deleter/ConfigDeleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use Generated\Shared\Transfer\AppDisconnectTransfer;
use Spryker\Shared\Log\LoggerTrait;
use Spryker\Zed\AppKernel\Persistence\AppKernelEntityManagerInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface;
use Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface;
use Throwable;

class ConfigDeleter implements ConfigDeleterInterface
Expand All @@ -27,13 +25,13 @@ class ConfigDeleter implements ConfigDeleterInterface

/**
* @param \Spryker\Zed\AppKernel\Persistence\AppKernelEntityManagerInterface $appEntityManager
* @param \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface|null $configurationBeforeDeletePlugin
* @param \Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface|null $configurationAfterDeletePlugin
* @param array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationBeforeDeletePluginInterface> $configurationBeforeDeletePlugin
* @param array<\Spryker\Zed\AppKernelExtension\Dependency\Plugin\ConfigurationAfterDeletePluginInterface> $configurationAfterDeletePlugin
*/
public function __construct(
protected AppKernelEntityManagerInterface $appEntityManager,
protected ?ConfigurationBeforeDeletePluginInterface $configurationBeforeDeletePlugin = null,
protected ?ConfigurationAfterDeletePluginInterface $configurationAfterDeletePlugin = null
protected array $configurationBeforeDeletePlugin = [],
protected array $configurationAfterDeletePlugin = []
) {
}

Expand All @@ -45,9 +43,7 @@ public function __construct(
public function deleteConfig(AppDisconnectTransfer $appDisconnectTransfer): AppDisconnectResponseTransfer
{
try {
if ($this->configurationBeforeDeletePlugin) {
$appDisconnectTransfer = $this->configurationBeforeDeletePlugin->beforeDelete($appDisconnectTransfer);
}
$this->executeConfigurationBeforeDeletePlugin($appDisconnectTransfer);

$appConfigCriteriaTransfer = (new AppConfigCriteriaTransfer())
->fromArray($appDisconnectTransfer->toArray(), true);
Expand All @@ -60,9 +56,7 @@ public function deleteConfig(AppDisconnectTransfer $appDisconnectTransfer): AppD
->setErrorMessage(static::DISCONNECT_ERROR_MESSAGE);
}

if ($this->configurationAfterDeletePlugin) {
$this->configurationAfterDeletePlugin->afterDelete($appDisconnectTransfer);
}
$this->executeConfigurationAfterDeletePlugin($appDisconnectTransfer);

return (new AppDisconnectResponseTransfer())->setIsSuccessful(true);
} catch (Throwable $throwable) {
Expand All @@ -71,4 +65,28 @@ public function deleteConfig(AppDisconnectTransfer $appDisconnectTransfer): AppD
->setErrorMessage(sprintf('%s: %s', static::DISCONNECT_ERROR_MESSAGE, $throwable->getMessage()));
}
}

/**
* @param \Generated\Shared\Transfer\AppDisconnectTransfer $appDisconnectTransfer
*
* @return void
*/
protected function executeConfigurationBeforeDeletePlugin(AppDisconnectTransfer $appDisconnectTransfer): void
{
foreach ($this->configurationBeforeDeletePlugin as $configurationBeforeDeletePlugin) {
$configurationBeforeDeletePlugin->beforeDelete($appDisconnectTransfer);
}
}

/**
* @param \Generated\Shared\Transfer\AppDisconnectTransfer $appDisconnectTransfer
*
* @return void
*/
protected function executeConfigurationAfterDeletePlugin(AppDisconnectTransfer $appDisconnectTransfer): void
{
foreach ($this->configurationAfterDeletePlugin as $configurationAfterDeletePlugin) {
$configurationAfterDeletePlugin->afterDelete($appDisconnectTransfer);
}
}
}
3 changes: 0 additions & 3 deletions src/Spryker/Zed/AppKernel/Business/Reader/ConfigReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

use Generated\Shared\Transfer\AppConfigCriteriaTransfer;
use Spryker\Client\SecretsManager\Exception\MissingSecretsManagerProviderPluginException;
use Spryker\Client\SecretsManager\SecretsManagerDependencyProvider;
use Spryker\Client\SecretsManagerExtension\Dependency\Plugin\SecretsManagerProviderPluginInterface;
use Spryker\Shared\Kernel\Transfer\TransferInterface;
use Spryker\Shared\Log\LoggerTrait;
use Spryker\Zed\AppKernel\Business\EncryptionConfigurator\PropelEncryptionConfiguratorInterface;
Expand Down Expand Up @@ -53,7 +51,6 @@ protected function configurePropelEncryption(AppConfigCriteriaTransfer $appConfi
try {
$this->propelEncryptionConfigurator->configurePropelEncryption($appConfigCriteriaTransfer->getTenantIdentifierOrFail());
} catch (MissingSecretsManagerProviderPluginException) {
$this->getLogger()->warning(sprintf('There is no %s attached to %s::getSecretsManagerProviderPlugin(). This leads to unencrypted data in the database which should be avoided.', SecretsManagerProviderPluginInterface::class, SecretsManagerDependencyProvider::class));
}
}
}
Loading

0 comments on commit 28c3cc5

Please sign in to comment.