Skip to content

Commit

Permalink
Merge pull request #1 from valantic-CEC-Deutschland-GmbH/feature/SPRY…
Browse files Browse the repository at this point in the history
…-3032

SPRY-3032 Rename CacheManagerGui namespace to CacheManager in CacheMa…
  • Loading branch information
HaukeBST authored May 22, 2024
2 parents 273248d + 9dc92b2 commit 5a52b65
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManager\Business;

use Spryker\Client\Storage\StorageClientInterface;
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;
use ValanticSpryker\Zed\CacheManager\Business\Model\CacheManager;
use ValanticSpryker\Zed\CacheManager\CacheManagerDependencyProvider;
use ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginCollection;

class CacheManagerBusinessFactory extends AbstractBusinessFactory
{
/**
* @return \ValanticSpryker\Zed\CacheManager\Business\Model\CacheManager
*/
public function createCacheManager(): CacheManager
{
return new CacheManager(
$this->createCacheManagerPluginCollection(),
$this->getStorageClient(),
);
}

/**
* @return \ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginCollection
*/
protected function createCacheManagerPluginCollection(): CacheManagerPluginCollection
{
return new CacheManagerPluginCollection($this->getCacheManagerPlugins());
}

/**
* @return array<\ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginInterface>
*/
protected function getCacheManagerPlugins(): array
{
return $this->getProvidedDependency(CacheManagerDependencyProvider::CACHE_MANAGER_PLUGINS);
}

/**
* @return \Spryker\Client\Storage\StorageClientInterface
*/
protected function getStorageClient(): StorageClientInterface
{
return $this->getProvidedDependency(CacheManagerDependencyProvider::CLIENT_STORAGE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManager\Business;

use Generated\Shared\Transfer\CacheManagerDeleteTransfer;
use Spryker\Zed\Kernel\Business\AbstractFacade;

/**
* @method \ValanticSpryker\Zed\CacheManager\Business\CacheManagerBusinessFactory getFactory()
*/
class CacheManagerFacade extends AbstractFacade implements CacheManagerFacadeInterface
{
/**
* @return array<\Generated\Shared\Transfer\CacheManagerPluginTransfer>
*/
public function getCacheManagerPluginsData(): array
{
return $this->getFactory()->createCacheManager()->getPlugins();
}

/**
* @param \Generated\Shared\Transfer\CacheManagerDeleteTransfer $cacheManagerDeleteTransfer
*
* @return \Generated\Shared\Transfer\CacheManagerDeleteTransfer
*/
public function deleteCache(CacheManagerDeleteTransfer $cacheManagerDeleteTransfer): CacheManagerDeleteTransfer
{
return $this->getFactory()->createCacheManager()->deleteCache($cacheManagerDeleteTransfer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManager\Business;

use Generated\Shared\Transfer\CacheManagerDeleteTransfer;

interface CacheManagerFacadeInterface
{
/**
* @return array<\Generated\Shared\Transfer\CacheManagerPluginTransfer>
*/
public function getCacheManagerPluginsData(): array;

/**
* @param \Generated\Shared\Transfer\CacheManagerDeleteTransfer $cacheManagerDeleteTransfer
*
* @return \Generated\Shared\Transfer\CacheManagerDeleteTransfer
*/
public function deleteCache(CacheManagerDeleteTransfer $cacheManagerDeleteTransfer): CacheManagerDeleteTransfer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManagerGui\Business\Model;
namespace ValanticSpryker\Zed\CacheManager\Business\Model;

use Generated\Shared\Transfer\CacheManagerDeleteTransfer;
use Generated\Shared\Transfer\CacheManagerPluginTransfer;
use Spryker\Client\Storage\Redis\Service;
use Spryker\Client\Storage\StorageClientInterface;
use ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginCollection;
use ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginCollection;

class CacheManager
{
/**
* @param \ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginCollection $cacheManagerPluginCollection
* @param \ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginCollection $cacheManagerPluginCollection
* @param \Spryker\Client\Storage\StorageClientInterface $storageClient
*/
public function __construct(private CacheManagerPluginCollection $cacheManagerPluginCollection, private StorageClientInterface $storageClient)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManager;

use Spryker\Client\Storage\StorageClientInterface;
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
use Spryker\Zed\Kernel\Container;

class CacheManagerDependencyProvider extends AbstractBundleDependencyProvider
{
public const CACHE_MANAGER_PLUGINS = 'CACHE_MANAGER_PLUGINS';
public const CLIENT_STORAGE = 'CLIENT_STORAGE';

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
public function provideBusinessLayerDependencies(Container $container): Container
{
$container = parent::provideBusinessLayerDependencies($container);

$this->addCacheManagerPlugins($container);
$this->addStorageClient($container);

return $container;
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return void
*/
protected function addCacheManagerPlugins(Container $container): void
{
$container->set(self::CACHE_MANAGER_PLUGINS, function () {
return $this->getCacheManagerPlugins();
});
}

/**
* @return array<\ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginInterface>
*/
protected function getCacheManagerPlugins(): array
{
return [];
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return void
*/
protected function addStorageClient(Container $container): void
{
$container->set(
self::CLIENT_STORAGE,
fn (): StorageClientInterface => $container->getLocator()->storage()->client(), // @phpstan-ignore method.notFound
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin;
namespace ValanticSpryker\Zed\CacheManager\Communication\Plugin;

use InvalidArgumentException;

Expand All @@ -11,7 +11,7 @@ class CacheManagerPluginCollection
private array $plugins = [];

/**
* @param array<\ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginInterface> $plugins
* @param array<\ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginInterface> $plugins
*/
public function __construct(array $plugins)
{
Expand All @@ -21,7 +21,7 @@ public function __construct(array $plugins)
}

/**
* @param \ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginInterface $plugin
* @param \ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginInterface $plugin
*
* @return void
*/
Expand All @@ -35,7 +35,7 @@ public function add(CacheManagerPluginInterface $plugin): void
*
* @throws \InvalidArgumentException
*
* @return \ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginInterface
* @return \ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginInterface
*/
public function get(string $name): CacheManagerPluginInterface
{
Expand All @@ -57,7 +57,7 @@ public function has(string $name): bool
}

/**
* @return array<\ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginInterface>
* @return array<\ValanticSpryker\Zed\CacheManager\Communication\Plugin\CacheManagerPluginInterface>
*/
public function getAll(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin;
namespace ValanticSpryker\Zed\CacheManager\Communication\Plugin;

interface CacheManagerPluginInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,17 @@

namespace ValanticSpryker\Zed\CacheManagerGui\Business;

use Spryker\Client\Storage\StorageClientInterface;
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;
use ValanticSpryker\Zed\CacheManagerGui\Business\Model\CacheManager;
use ValanticSpryker\Zed\CacheManager\Business\CacheManagerFacadeInterface;
use ValanticSpryker\Zed\CacheManagerGui\CacheManagerGuiDependencyProvider;
use ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginCollection;

class CacheManagerGuiBusinessFactory extends AbstractBusinessFactory
{
/**
* @return \ValanticSpryker\Zed\CacheManagerGui\Business\Model\CacheManager
* @return \ValanticSpryker\Zed\CacheManager\Business\CacheManagerFacadeInterface
*/
public function createCacheManager(): CacheManager
public function getCacheManagerFacade(): CacheManagerFacadeInterface
{
return new CacheManager(
$this->createCacheManagerPluginCollection(),
$this->getStorageClient(),
);
}

/**
* @return \ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginCollection
*/
protected function createCacheManagerPluginCollection(): CacheManagerPluginCollection
{
return new CacheManagerPluginCollection($this->getCacheManagerPlugins());
}

/**
* @return array<\ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginInterface>
*/
protected function getCacheManagerPlugins(): array
{
return $this->getProvidedDependency(CacheManagerGuiDependencyProvider::CACHE_MANAGER_PLUGINS);
}

/**
* @return \Spryker\Client\Storage\StorageClientInterface
*/
protected function getStorageClient(): StorageClientInterface
{
return $this->getProvidedDependency(CacheManagerGuiDependencyProvider::CLIENT_STORAGE);
return $this->getProvidedDependency(CacheManagerGuiDependencyProvider::FACADE_CACHE_MANAGER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CacheManagerGuiFacade extends AbstractFacade implements CacheManagerGuiFac
*/
public function getCacheManagerPluginsData(): array
{
return $this->getFactory()->createCacheManager()->getPlugins();
return $this->getFactory()->getCacheManagerFacade()->getCacheManagerPluginsData();
}

/**
Expand All @@ -27,6 +27,6 @@ public function getCacheManagerPluginsData(): array
*/
public function deleteCache(CacheManagerDeleteTransfer $cacheManagerDeleteTransfer): CacheManagerDeleteTransfer
{
return $this->getFactory()->createCacheManager()->deleteCache($cacheManagerDeleteTransfer);
return $this->getFactory()->getCacheManagerFacade()->deleteCache($cacheManagerDeleteTransfer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Generated\Shared\Transfer\CacheManagerDeleteTransfer;

/**
* @method \ValanticSpryker\Zed\CacheManagerGui\Business\CacheManagerGuiBusinessFactory getFactory()
* @method \ValanticSpryker\Zed\CacheManager\Business\CacheManagerBusinessFactory getFactory()
*/
interface CacheManagerGuiFacadeInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

namespace ValanticSpryker\Zed\CacheManagerGui;

use Spryker\Client\Storage\StorageClientInterface;
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
use Spryker\Zed\Kernel\Container;

class CacheManagerGuiDependencyProvider extends AbstractBundleDependencyProvider
{
public const CACHE_MANAGER_PLUGINS = 'CACHE_MANAGER_PLUGINS';
public const CLIENT_STORAGE = 'CLIENT_STORAGE';
public const FACADE_CACHE_MANAGER = 'FACADE_CACHE_MANAGER';

/**
* @param \Spryker\Zed\Kernel\Container $container
Expand All @@ -22,8 +20,7 @@ public function provideBusinessLayerDependencies(Container $container): Containe
{
$container = parent::provideBusinessLayerDependencies($container);

$this->addCacheManagerPlugins($container);
$this->addStorageClient($container);
$this->addCacheManagerFacade($container);

return $container;
}
Expand All @@ -33,31 +30,10 @@ public function provideBusinessLayerDependencies(Container $container): Containe
*
* @return void
*/
protected function addCacheManagerPlugins(Container $container): void
private function addCacheManagerFacade(Container $container): void
{
$container->set(self::CACHE_MANAGER_PLUGINS, function () {
return $this->getCacheManagerPlugins();
$container->set(static::FACADE_CACHE_MANAGER, function (Container $container) {
return $container->getLocator()->cacheManager()->facade(); // @phpstan-ignore method.notFound
});
}

/**
* @return array<\ValanticSpryker\Zed\CacheManagerGui\Communication\Plugin\CacheManagerPluginInterface>
*/
protected function getCacheManagerPlugins(): array
{
return [];
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return void
*/
protected function addStorageClient(Container $container): void
{
$container->set(
self::CLIENT_STORAGE,
fn (): StorageClientInterface => $container->getLocator()->storage()->client()
);
}
}

0 comments on commit 5a52b65

Please sign in to comment.