Skip to content

Commit

Permalink
SPRY-3032 Rename CacheManagerGui namespace to CacheManager in CacheMa…
Browse files Browse the repository at this point in the history
…nager model and related classes.
  • Loading branch information
HaukeBST committed May 21, 2024
1 parent 273248d commit 212c57d
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 75 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,31 @@
<?php

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManager\Business;

use ValanticSpryker\Zed\CacheManager\Business\CacheManagerFacadeInterface;

/**
* @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,10 @@
<?php

declare(strict_types = 1);

namespace ValanticSpryker\Zed\CacheManager\Business;

interface CacheManagerFacadeInterface
{

}
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()
);
}
}
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
private function getCacheManagerFacade(): CacheManagerFacadeInterface
{
return new CacheManager(
$this->createCacheManagerPluginCollection(),
$this->getStorageClient(),
);
return $this->getProvidedDependency(CacheManagerGuiDependencyProvider::FACADE_CACHE_MANAGER);
}

/**
* @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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

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

/**
* @method \ValanticSpryker\Zed\CacheManagerGui\Business\CacheManagerGuiBusinessFactory getFactory()
* @method \ValanticSpryker\Zed\CacheManager\Business\CacheManagerBusinessFactory getFactory()
*/
class CacheManagerGuiFacade extends AbstractFacade implements CacheManagerGuiFacadeInterface
{
Expand All @@ -17,7 +18,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 +28,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 @@ -10,8 +10,7 @@

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 +21,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 +31,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();
});
}

/**
* @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 212c57d

Please sign in to comment.