Skip to content

Commit

Permalink
Fix backward incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ackintosh committed Dec 15, 2020
1 parent a225863 commit 7abb09a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Ganesha/Storage/Adapter/Apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public function setContext(Ganesha\Context $context): void
$this->storageKeys = $context->configuration()->storageKeys();
}

/**
* @inheritdoc
*/
public function setConfiguration(Configuration $configuration): void
{
// nop
}

/**
* @param string $key
* @return int
Expand Down
8 changes: 8 additions & 0 deletions src/Ganesha/Storage/Adapter/Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public function setContext(Ganesha\Context $context): void
$this->context = $context;
}

/**
* @inheritdoc
*/
public function setConfiguration(Configuration $configuration): void
{
// nop
}

/**
* @param string $service
* @return int
Expand Down
8 changes: 8 additions & 0 deletions src/Ganesha/Storage/Adapter/MongoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public function setContext(Ganesha\Context $context): void
// This adapter doesn't use the context.
}

/**
* @inheritdoc
*/
public function setConfiguration(Configuration $configuration): void
{
// nop
}

/**
* @param string $service
* @return int
Expand Down
8 changes: 8 additions & 0 deletions src/Ganesha/Storage/Adapter/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public function setContext(Ganesha\Context $context): void
$this->configuration = $context->configuration();
}

/**
* @inheritdoc
*/
public function setConfiguration(Configuration $configuration): void
{
// nop
}

/**
* @param string $service
*
Expand Down
8 changes: 8 additions & 0 deletions src/Ganesha/Storage/AdapterInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Ackintosh\Ganesha\Storage;

use Ackintosh\Ganesha\Configuration;
use Ackintosh\Ganesha\Context;

interface AdapterInterface
Expand All @@ -23,6 +24,13 @@ public function supportRateStrategy(): bool ;
*/
public function setContext(Context $context): void;

/**
* @deprecated This param will be removed in the next major release. Please use `setContext` instead.
* @param Configuration $configuration
* @return void
*/
public function setConfiguration(Configuration $configuration): void;

/**
* @param string $service
* @return int
Expand Down
3 changes: 3 additions & 0 deletions src/Ganesha/Traits/BuildGanesha.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function build(): Ganesha

$configuration = new Configuration($this->params);
$context = new Ganesha\Context(self::$strategyClass, $adapter, $configuration);

// AdapterInterface::setConfiguration() is deprecated since 1.2.2. This will be removed in the next major release.
$adapter->setConfiguration($configuration);
$adapter->setContext($context);

return new Ganesha(self::$strategyClass::create($adapter, $configuration));
Expand Down

0 comments on commit 7abb09a

Please sign in to comment.