Skip to content

Commit

Permalink
Add interface and use trait to make the config service a cacheable de…
Browse files Browse the repository at this point in the history
…pendency... (#41)

... really, just inheriting cachability from the config at which it points.
  • Loading branch information
adam-vessey authored Aug 31, 2022
1 parent cd8f6df commit c55e1e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\openseadragon;

use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
use Drupal\Core\Config\ConfigFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

Expand All @@ -12,6 +13,8 @@
*/
class Config implements ConfigInterface {

use RefinableCacheableDependencyTrait;

/**
* The openseadragon config.
*
Expand Down Expand Up @@ -49,6 +52,7 @@ class Config implements ConfigInterface {
public function __construct(ConfigFactoryInterface $configFactory) {
$this->config = $configFactory->get(Config::$configName);
$this->configFactory = $configFactory;
$this->addCacheableDependency($this->config);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Drupal\openseadragon;

use Drupal\Core\Cache\CacheableDependencyInterface;

/**
* Special config class.
*
* This class allows the default config structure to remain, this is used to
* clean up the settings form values and remove extra unnecessary arrays.
*/
interface ConfigInterface {
interface ConfigInterface extends CacheableDependencyInterface {

/**
* Get the default viewer settings.
Expand Down

0 comments on commit c55e1e6

Please sign in to comment.